libapreq2-2.12: 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 **  Licensed to the Apache Software Foundation (ASF) under one or more
    00003 ** contributor license agreements.  See the NOTICE file distributed with
    00004 ** this work for additional information regarding copyright ownership.
    00005 ** The ASF licenses this file to You under the Apache License, Version 2.0
    00006 ** (the "License"); you may not use this file except in compliance with
    00007 ** the License.  You may obtain a copy of the License at
    00008 **
    00009 **      http://www.apache.org/licenses/LICENSE-2.0
    00010 **
    00011 **  Unless required by applicable law or agreed to in writing, software
    00012 **  distributed under the License is distributed on an "AS IS" BASIS,
    00013 **  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00014 **  See the License for the specific language governing permissions and
    00015 **  limitations under the License.
    00016 */
    00017
    00018 #ifndef APREQ_MODULE_H
    00019 #define APREQ_MODULE_H
    00020
    00021 #include "apreq_cookie.h"
    00022 #include "apreq_parser.h"
    00023 #include "apreq_error.h"
    00024
    00025 #ifdef  __cplusplus
    00026  extern "C" {
    00027 #endif
    00028
    00041 typedef struct apreq_handle_t {
    00043     const struct apreq_module_t *module;
    00045     apr_pool_t *pool;
    00047     apr_bucket_alloc_t *bucket_alloc;
    00048
    00049 } apreq_handle_t;
    00050
    00056 typedef struct apreq_module_t {
    00058     const char *name;
    00060     apr_uint32_t magic_number;
    00061
    00063     apr_status_t (*jar)(apreq_handle_t *, const apr_table_t **);
    00065     apr_status_t (*args)(apreq_handle_t *, const apr_table_t **);
    00067     apr_status_t (*body)(apreq_handle_t *, const apr_table_t **);
    00068
    00070     apreq_cookie_t *(*jar_get)(apreq_handle_t *, const char *);
    00072     apreq_param_t *(*args_get)(apreq_handle_t *, const char *);
    00074     apreq_param_t *(*body_get)(apreq_handle_t *, const char *);
    00075
    00077     apr_status_t (*parser_get)(apreq_handle_t *, const apreq_parser_t **);
    00079     apr_status_t (*parser_set)(apreq_handle_t *, apreq_parser_t *);
    00081     apr_status_t (*hook_add)(apreq_handle_t *, apreq_hook_t *);
    00082
    00084     apr_status_t (*brigade_limit_get)(apreq_handle_t *, apr_size_t *);
    00086     apr_status_t (*brigade_limit_set)(apreq_handle_t *, apr_size_t);
    00087
    00089     apr_status_t (*read_limit_get)(apreq_handle_t *, apr_uint64_t *);
    00091     apr_status_t (*read_limit_set)(apreq_handle_t *, apr_uint64_t);
    00092
    00094     apr_status_t (*temp_dir_get)(apreq_handle_t *, const char **);
    00096     apr_status_t (*temp_dir_set)(apreq_handle_t *, const char *);
    00097
    00098 } apreq_module_t;
    00099
    00100
    00109 static APR_INLINE
    00110 unsigned apreq_module_status_is_error(apr_status_t s) {
    00111     switch (s) {
    00112     case APR_SUCCESS:
    00113     case APR_INCOMPLETE:
    00114     case APR_EINIT:
    00115     case APREQ_ERROR_NODATA:
    00116     case APREQ_ERROR_NOPARSER:
    00117     case APREQ_ERROR_NOHEADER:
    00118         return 0;
    00119     default:
    00120         return 1;
    00121     }
    00122 }
    00123
    00124
    00134 static APR_INLINE
    00135 apr_status_t apreq_jar(apreq_handle_t *req, const apr_table_t **t)
    00136 {
    00137     return req->module->jar(req,t);
    00138 }
    00139
    00149 static APR_INLINE
    00150 apr_status_t apreq_args(apreq_handle_t *req, const apr_table_t **t)
    00151 {
    00152     return req->module->args(req,t);
    00153 }
    00154
    00164 static APR_INLINE
    00165 apr_status_t apreq_body(apreq_handle_t *req, const apr_table_t **t)
    00166 {
    00167     return req->module->body(req, t);
    00168 }
    00169
    00170
    00179 static APR_INLINE
    00180 apreq_cookie_t *apreq_jar_get(apreq_handle_t *req, const char *name)
    00181 {
    00182     return req->module->jar_get(req, name);
    00183 }
    00184
    00193 static APR_INLINE
    00194 apreq_param_t *apreq_args_get(apreq_handle_t *req, const char *name)
    00195 {
    00196     return req->module->args_get(req, name);
    00197 }
    00198
    00207 static APR_INLINE
    00208 apreq_param_t *apreq_body_get(apreq_handle_t *req, const char *name)
    00209 {
    00210     return req->module->body_get(req, name);
    00211 }
    00212
    00222 static APR_INLINE
    00223 apr_status_t apreq_parser_get(apreq_handle_t *req,
    00224                               const apreq_parser_t **parser)
    00225 {
    00226     return req->module->parser_get(req, parser);
    00227 }
    00228
    00229
    00238 static APR_INLINE
    00239 apr_status_t apreq_parser_set(apreq_handle_t *req,
    00240                               apreq_parser_t *parser)
    00241 {
    00242     return req->module->parser_set(req, parser);
    00243 }
    00244
    00253 static APR_INLINE
    00254 apr_status_t apreq_hook_add(apreq_handle_t *req, apreq_hook_t *hook)
    00255 {
    00256     return req->module->hook_add(req, hook);
    00257 }
    00258
    00259
    00269 static APR_INLINE
    00270 apr_status_t apreq_brigade_limit_set(apreq_handle_t *req,
    00271                                      apr_size_t bytes)
    00272 {
    00273     return req->module->brigade_limit_set(req, bytes);
    00274 }
    00275
    00285 static APR_INLINE
    00286 apr_status_t apreq_brigade_limit_get(apreq_handle_t *req,
    00287                                      apr_size_t *bytes)
    00288 {
    00289     return req->module->brigade_limit_get(req, bytes);
    00290 }
    00291
    00301 static APR_INLINE
    00302 apr_status_t apreq_read_limit_set(apreq_handle_t *req,
    00303                                   apr_uint64_t bytes)
    00304 {
    00305     return req->module->read_limit_set(req, bytes);
    00306 }
    00307
    00317 static APR_INLINE
    00318 apr_status_t apreq_read_limit_get(apreq_handle_t *req,
    00319                                   apr_uint64_t *bytes)
    00320 {
    00321     return req->module->read_limit_get(req, bytes);
    00322 }
    00323
    00332 static APR_INLINE
    00333 apr_status_t apreq_temp_dir_set(apreq_handle_t *req, const char *path)
    00334 {
    00335     return req->module->temp_dir_set(req, path);
    00336 }
    00337
    00348 static APR_INLINE
    00349 apr_status_t apreq_temp_dir_get(apreq_handle_t *req, const char **path)
    00350 {
    00351     return req->module->temp_dir_get(req, path);
    00352 }
    00353
    00354
    00355
    00366 #define APREQ_MODULE(pre, mmn) const apreq_module_t     \
    00367   pre##_module = { #pre, mmn,                           \
    00368   pre##_jar,        pre##_args,       pre##_body,       \
    00369   pre##_jar_get,    pre##_args_get,   pre##_body_get,   \
    00370   pre##_parser_get, pre##_parser_set, pre##_hook_add,   \
    00371   pre##_brigade_limit_get, pre##_brigade_limit_set,     \
    00372   pre##_read_limit_get,    pre##_read_limit_set,        \
    00373   pre##_temp_dir_get,      pre##_temp_dir_set,          \
    00374   }
    00375
    00376
    00388 APREQ_DECLARE(apreq_handle_t*) apreq_handle_cgi(apr_pool_t *pool);
    00389
    00404 APREQ_DECLARE(apreq_handle_t*) apreq_handle_custom(apr_pool_t *pool,
    00405                                                    const char *query_string,
    00406                                                    const char *cookie,
    00407                                                    apreq_parser_t *parser,
    00408                                                    apr_uint64_t read_limit,
    00409                                                    apr_bucket_brigade *in);
    00410
    00420 APREQ_DECLARE(apreq_param_t *)apreq_param(apreq_handle_t *req, const char *key);
    00421
    00431 #define apreq_cookie(req, name) apreq_jar_get(req, name)
    00432
    00442 APREQ_DECLARE(apr_table_t *) apreq_params(apreq_handle_t *req, apr_pool_t *p);
    00443
    00444
    00451 APREQ_DECLARE(apr_table_t *)apreq_cookies(apreq_handle_t *req, apr_pool_t *p);
    00452
    00453 #ifdef __cplusplus
    00454  }
    00455 #endif
    00456
    00457 #endif /* APREQ_MODULE_H */