libapreq2-2.13: libapreq2: include/apreq_util.h Source File

Apache Software Foundation > HTTP Server Project > Request Library Subproject

Apache HTTP Server Request Library

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

# include/apreq_util.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_UTIL_H
    00019 #define APREQ_UTIL_H
    00020
    00021 #include "apr_file_io.h"
    00022 #include "apr_buckets.h"
    00023 #include "apreq.h"
    00024
    00025 #ifdef  __cplusplus
    00026  extern "C" {
    00027 #endif
    00028
    00053 APREQ_DECLARE(char *) apreq_join(apr_pool_t *p,
    00054                                  const char *sep,
    00055                                  const apr_array_header_t *arr,
    00056                                  apreq_join_t mode);
    00057
    00070 APREQ_DECLARE(apr_ssize_t) apreq_index(const char* hay, apr_size_t hlen,
    00071                                        const char* ndl, apr_size_t nlen,
    00072                                        const apreq_match_t type);
    00073
    00086 APREQ_DECLARE(apr_size_t) apreq_quote(char *dest, const char *src,
    00087                                       const apr_size_t slen);
    00088
    00102 APREQ_DECLARE(apr_size_t) apreq_quote_once(char *dest, const char *src,
    00103                                            const apr_size_t slen);
    00104
    00115 APREQ_DECLARE(apr_size_t) apreq_encode(char *dest, const char *src,
    00116                                        const apr_size_t slen);
    00117
    00129 APREQ_DECLARE(apr_size_t) apreq_cp1252_to_utf8(char *dest,
    00130                                                const char *src, apr_size_t slen);
    00131
    00143 APREQ_DECLARE(apreq_charset_t) apreq_charset_divine(const char *src,
    00144                                                     apr_size_t slen);
    00145
    00166 APREQ_DECLARE(apr_status_t) apreq_decode(char *dest, apr_size_t *dlen,
    00167                                          const char *src, apr_size_t slen);
    00168
    00189 APREQ_DECLARE(apr_status_t) apreq_decodev(char *dest, apr_size_t *dlen,
    00190                                           struct iovec *v, int nelts);
    00191
    00204 static APR_INLINE
    00205 char *apreq_escape(apr_pool_t *p, const char *src, const apr_size_t slen)
    00206 {
    00207     char *rv;
    00208
    00209     if (src == NULL)
    00210         return NULL;
    00211
    00212     rv = (char *)apr_palloc(p, 3 * slen + 1);
    00213     apreq_encode(rv, src, slen);
    00214     return rv;
    00215 }
    00216
    00224 static APR_INLINE apr_ssize_t apreq_unescape(char *str)
    00225 {
    00226     apr_size_t len;
    00227     apr_status_t rv = apreq_decode(str, &len, str, strlen(str));
    00228     if (rv == APR_SUCCESS)
    00229         return (apr_ssize_t)len;
    00230     else
    00231         return -1;
    00232 }
    00233
    00245 APREQ_DECLARE(apr_int64_t) apreq_atoi64f(const char *s);
    00246
    00258 APREQ_DECLARE(apr_int64_t) apreq_atoi64t(const char *s);
    00259
    00277 APREQ_DECLARE(apr_status_t) apreq_brigade_fwrite(apr_file_t *f,
    00278                                                  apr_off_t *wlen,
    00279                                                  apr_bucket_brigade *bb);
    00296 APREQ_DECLARE(apr_status_t) apreq_file_mktemp(apr_file_t **fp,
    00297                                               apr_pool_t *pool,
    00298                                               const char *path);
    00299
    00309 static APR_INLINE
    00310 apr_status_t apreq_brigade_setaside(apr_bucket_brigade *bb, apr_pool_t *p)
    00311 {
    00312     apr_bucket *e;
    00313     for (e = APR_BRIGADE_FIRST(bb); e != APR_BRIGADE_SENTINEL(bb);
    00314          e = APR_BUCKET_NEXT(e))
    00315     {
    00316         apr_status_t rv = apr_bucket_setaside(e, p);
    00317         if (rv != APR_SUCCESS)
    00318             return rv;
    00319     }
    00320     return APR_SUCCESS;
    00321 }
    00322
    00323
    00336 static APR_INLINE
    00337 apr_status_t apreq_brigade_copy(apr_bucket_brigade *d, apr_bucket_brigade *s) {
    00338     apr_bucket *e;
    00339     for (e = APR_BRIGADE_FIRST(s); e != APR_BRIGADE_SENTINEL(s);
    00340          e = APR_BUCKET_NEXT(e))
    00341     {
    00342         apr_bucket *c;
    00343         apr_status_t rv = apr_bucket_copy(e, &c);
    00344         if (rv != APR_SUCCESS)
    00345             return rv;
    00346
    00347         APR_BRIGADE_INSERT_TAIL(d, c);
    00348     }
    00349     return APR_SUCCESS;
    00350 }
    00351
    00363 static APR_INLINE
    00364 void apreq_brigade_move(apr_bucket_brigade *d, apr_bucket_brigade *s,
    00365                         apr_bucket *e)
    00366 {
    00367     apr_bucket *f;
    00368
    00369     if (e != APR_BRIGADE_SENTINEL(s)) {
    00370         f = APR_RING_FIRST(&s->list);
    00371         if (f == e) /* zero buckets to be moved */
    00372             return;
    00373
    00374         /* obtain the last bucket to be moved */
    00375         e = APR_RING_PREV(e, link);
    00376
    00377         APR_RING_UNSPLICE(f, e, link);
    00378         APR_RING_SPLICE_HEAD(&d->list, f, e, apr_bucket, link);
    00379     }
    00380     else {
    00381         APR_BRIGADE_CONCAT(d, s);
    00382     }
    00383 }
    00384
    00385
    00399 APREQ_DECLARE(apr_status_t) apreq_header_attribute(const char *hdr,
    00400                                                    const char *name,
    00401                                                    const apr_size_t nlen,
    00402                                                    const char **val,
    00403                                                    apr_size_t *vlen);
    00404
    00405
    00423 APREQ_DECLARE(apr_status_t) apreq_brigade_concat(apr_pool_t *pool,
    00424                                                  const char *temp_dir,
    00425                                                  apr_size_t brigade_limit,
    00426                                                  apr_bucket_brigade *out,
    00427                                                  apr_bucket_brigade *in);
    00428
    00437 APREQ_DECLARE(apr_file_t *)apreq_brigade_spoolfile(apr_bucket_brigade *bb);
    00438
    00439 #ifdef __cplusplus
    00440  }
    00441 #endif
    00442
    00443 #endif /* APREQ_UTIL_H */

Copyright © 2003-2006 The Apache Software Foundation.
See LICENSE.

page generated by `doxygen` version 1.5.6 on 25 Nov 2010