libapreq2-2.08: libapreq2: include/apreq_module.h Source File

Apache HTTP Server Request Library

- Main Page
- Modules
- Data Structures
- Files
- Related Pages
- Examples

- File List
- Globals

# include/apreq_module.h

Go to the documentation of this file.

    00001 /*
    00002 **  Copyright 2003-2006  The Apache Software Foundation
    00003 **
    00004 **  Licensed under the Apache License, Version 2.0 (the "License");
    00005 **  you may not use this file except in compliance with the License.
    00006 **  You may obtain a copy of the License at
    00007 **
    00008 **      http://www.apache.org/licenses/LICENSE-2.0
    00009 **
    00010 **  Unless required by applicable law or agreed to in writing, software
    00011 **  distributed under the License is distributed on an "AS IS" BASIS,
    00012 **  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00013 **  See the License for the specific language governing permissions and
    00014 **  limitations under the License.
    00015 */
    00016
    00017 #ifndef APREQ_MODULE_H
    00018 #define APREQ_MODULE_H
    00019
    00020 #include "apreq_cookie.h"
    00021 #include "apreq_parser.h"
    00022 #include "apreq_error.h"
    00023
    00024 #ifdef  __cplusplus
    00025  extern "C" {
    00026 #endif
    00027
    00040 typedef struct apreq_handle_t {
    00042     const struct apreq_module_t *module;
    00044     apr_pool_t *pool;
    00046     apr_bucket_alloc_t *bucket_alloc;
    00047
    00048 } apreq_handle_t;
    00049
    00055 typedef struct apreq_module_t {
    00057     const char *name;
    00059     apr_uint32_t magic_number;
    00060
    00062     apr_status_t (*jar)(apreq_handle_t *, const apr_table_t **);
    00064     apr_status_t (*args)(apreq_handle_t *, const apr_table_t **);
    00066     apr_status_t (*body)(apreq_handle_t *, const apr_table_t **);
    00067
    00069     apreq_cookie_t *(*jar_get)(apreq_handle_t *, const char *);
    00071     apreq_param_t *(*args_get)(apreq_handle_t *, const char *);
    00073     apreq_param_t *(*body_get)(apreq_handle_t *, const char *);
    00074
    00076     apr_status_t (*parser_get)(apreq_handle_t *, const apreq_parser_t **);
    00078     apr_status_t (*parser_set)(apreq_handle_t *, apreq_parser_t *);
    00080     apr_status_t (*hook_add)(apreq_handle_t *, apreq_hook_t *);
    00081
    00083     apr_status_t (*brigade_limit_get)(apreq_handle_t *, apr_size_t *);
    00085     apr_status_t (*brigade_limit_set)(apreq_handle_t *, apr_size_t);
    00086
    00088     apr_status_t (*read_limit_get)(apreq_handle_t *, apr_uint64_t *);
    00090     apr_status_t (*read_limit_set)(apreq_handle_t *, apr_uint64_t);
    00091
    00093     apr_status_t (*temp_dir_get)(apreq_handle_t *, const char **);
    00095     apr_status_t (*temp_dir_set)(apreq_handle_t *, const char *);
    00096
    00097 } apreq_module_t;
    00098
    00099
    00108 static APR_INLINE
    00109 unsigned apreq_module_status_is_error(apr_status_t s) {
    00110     switch (s) {
    00111     case APR_SUCCESS:
    00112     case APR_INCOMPLETE:
    00113     case APR_EINIT:
    00114     case APREQ_ERROR_NODATA:
    00115     case APREQ_ERROR_NOPARSER:
    00116     case APREQ_ERROR_NOHEADER:
    00117         return 0;
    00118     default:
    00119         return 1;
    00120     }
    00121 }
    00122
    00123
    00133 static APR_INLINE
    00134 apr_status_t apreq_jar(apreq_handle_t *req, const apr_table_t **t)
    00135 {
    00136     return req->module->jar(req,t);
    00137 }
    00138
    00148 static APR_INLINE
    00149 apr_status_t apreq_args(apreq_handle_t *req, const apr_table_t **t)
    00150 {
    00151     return req->module->args(req,t);
    00152 }
    00153
    00163 static APR_INLINE
    00164 apr_status_t apreq_body(apreq_handle_t *req, const apr_table_t **t)
    00165 {
    00166     return req->module->body(req, t);
    00167 }
    00168
    00169
    00178 static APR_INLINE
    00179 apreq_cookie_t *apreq_jar_get(apreq_handle_t *req, const char *name)
    00180 {
    00181     return req->module->jar_get(req, name);
    00182 }
    00183
    00192 static APR_INLINE
    00193 apreq_param_t *apreq_args_get(apreq_handle_t *req, const char *name)
    00194 {
    00195     return req->module->args_get(req, name);
    00196 }
    00197
    00206 static APR_INLINE
    00207 apreq_param_t *apreq_body_get(apreq_handle_t *req, const char *name)
    00208 {
    00209     return req->module->body_get(req, name);
    00210 }
    00211
    00221 static APR_INLINE
    00222 apr_status_t apreq_parser_get(apreq_handle_t *req,
    00223                               const apreq_parser_t **parser)
    00224 {
    00225     return req->module->parser_get(req, parser);
    00226 }
    00227
    00228
    00237 static APR_INLINE
    00238 apr_status_t apreq_parser_set(apreq_handle_t *req,
    00239                               apreq_parser_t *parser)
    00240 {
    00241     return req->module->parser_set(req, parser);
    00242 }
    00243
    00252 static APR_INLINE
    00253 apr_status_t apreq_hook_add(apreq_handle_t *req, apreq_hook_t *hook)
    00254 {
    00255     return req->module->hook_add(req, hook);
    00256 }
    00257
    00258
    00268 static APR_INLINE
    00269 apr_status_t apreq_brigade_limit_set(apreq_handle_t *req,
    00270                                      apr_size_t bytes)
    00271 {
    00272     return req->module->brigade_limit_set(req, bytes);
    00273 }
    00274
    00284 static APR_INLINE
    00285 apr_status_t apreq_brigade_limit_get(apreq_handle_t *req,
    00286                                      apr_size_t *bytes)
    00287 {
    00288     return req->module->brigade_limit_get(req, bytes);
    00289 }
    00290
    00300 static APR_INLINE
    00301 apr_status_t apreq_read_limit_set(apreq_handle_t *req,
    00302                                   apr_uint64_t bytes)
    00303 {
    00304     return req->module->read_limit_set(req, bytes);
    00305 }
    00306
    00316 static APR_INLINE
    00317 apr_status_t apreq_read_limit_get(apreq_handle_t *req,
    00318                                   apr_uint64_t *bytes)
    00319 {
    00320     return req->module->read_limit_get(req, bytes);
    00321 }
    00322
    00331 static APR_INLINE
    00332 apr_status_t apreq_temp_dir_set(apreq_handle_t *req, const char *path)
    00333 {
    00334     return req->module->temp_dir_set(req, path);
    00335 }
    00336
    00347 static APR_INLINE
    00348 apr_status_t apreq_temp_dir_get(apreq_handle_t *req, const char **path)
    00349 {
    00350     return req->module->temp_dir_get(req, path);
    00351 }
    00352
    00353
    00354
    00365 #define APREQ_MODULE(pre, mmn) const apreq_module_t     \
    00366   pre##_module = { #pre, mmn,                           \
    00367   pre##_jar,        pre##_args,       pre##_body,       \
    00368   pre##_jar_get,    pre##_args_get,   pre##_body_get,   \
    00369   pre##_parser_get, pre##_parser_set, pre##_hook_add,   \
    00370   pre##_brigade_limit_get, pre##_brigade_limit_set,     \
    00371   pre##_read_limit_get,    pre##_read_limit_set,        \
    00372   pre##_temp_dir_get,      pre##_temp_dir_set,          \
    00373   }
    00374
    00375
    00387 APREQ_DECLARE(apreq_handle_t*) apreq_handle_cgi(apr_pool_t *pool);
    00388
    00403 APREQ_DECLARE(apreq_handle_t*) apreq_handle_custom(apr_pool_t *pool,
    00404                                                    const char *query_string,
    00405                                                    const char *cookie,
    00406                                                    apreq_parser_t *parser,
    00407                                                    apr_uint64_t read_limit,
    00408                                                    apr_bucket_brigade *in);
    00409
    00419 APREQ_DECLARE(apreq_param_t *)apreq_param(apreq_handle_t *req, const char *key);
    00420
    00430 #define apreq_cookie(req, name) apreq_jar_get(req, name)
    00431
    00441 APREQ_DECLARE(apr_table_t *) apreq_params(apreq_handle_t *req, apr_pool_t *p);
    00442
    00443
    00450 APREQ_DECLARE(apr_table_t *)apreq_cookies(apreq_handle_t *req, apr_pool_t *p);
    00451
    00452 #ifdef __cplusplus
    00453  }
    00454 #endif
    00455
    00456 #endif /* APREQ_MODULE_H */