~ubuntu-branches/ubuntu/oneiric/libapreq2/oneiric

« back to all changes in this revision

Viewing changes to library/util.c

  • Committer: Bazaar Package Importer
  • Author(s): Steinar H. Gunderson
  • Date: 2010-02-28 15:51:47 UTC
  • mfrom: (5.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100228155147-dflwg59lhyittzi7
Tags: 2.12-1
* New upstream release.
* Switch to dpkg-source 3.0 (quilt) format.
  * Split the Debian diff into two separate patches, and remove spurious
    junk that shouldn't have been there.
  * In clean, remove some stray files distclean forgets.
* Update debhelper compatibility level to 7.
  * Update debhelper build-dependency version.
  * Use dh_prep instead of dh_clean -k.
* Update Standards-Version to 3.8.4.
  * Change from ${Source-Version} to ${binary:Version} in inter-package
    dependencies.
  * In debian/copyright, refer to the Apache 2.0 license file from
    common-licenses instead of having the entire license text in the file.
    Also include the actual copyright in the file.
* Put all binary packages in their correct respective sections.
* Add ${misc:Depends} to all binary packages, and remove ${shlibs:Depends}
  from the -dev and -doc packages (which don't have any shared libraries).
* Run dh_shlibdeps on all packages, using the -a flag.
* Don't ignore errors on distclean; check for Makefile instead.
* Don't use full path to a2dismod in libapache2-mod-apreq2.postrm.
* Run libapache2-mod-apreq2.postrm script under sh -e, so errors are not
  ignored.
* Install the man pages that used to conflict with libapache-request-perl,
  which is now not in the stable release anymore.
* Don't set PREFIX= at make install time; only set prefix=.
  Seemingly, PREFIX= has no real effect at that point.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
**  Copyright 2003-2006  The Apache Software Foundation
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
 
2
**  Licensed to the Apache Software Foundation (ASF) under one or more
 
3
** contributor license agreements.  See the NOTICE file distributed with
 
4
** this work for additional information regarding copyright ownership.
 
5
** The ASF licenses this file to You under the Apache License, Version 2.0
 
6
** (the "License"); you may not use this file except in compliance with
 
7
** the License.  You may obtain a copy of the License at
7
8
**
8
9
**      http://www.apache.org/licenses/LICENSE-2.0
9
10
**
692
693
    return rv;
693
694
}
694
695
 
 
696
/*
 
697
 * This is intentionally not apr_file_writev()
 
698
 * note, this is iterative and not recursive
 
699
 */
695
700
APR_INLINE
696
701
static apr_status_t apreq_fwritev(apr_file_t *f, struct iovec *v,
697
702
                                  int *nelts, apr_size_t *bytes_written)
713
718
 
714
719
        /* see how far we've come */
715
720
        n = 0;
716
 
        while (n < *nelts && len >= v[n].iov_len)
 
721
 
 
722
#ifdef SOLARIS2
 
723
# ifdef __GNUC__
 
724
        /*
 
725
         * iovec.iov_len is a long here
 
726
         * which causes a comparison between 
 
727
         * signed(long) and unsigned(apr_size_t)
 
728
         *
 
729
         */
 
730
        while (n < *nelts && len >= (apr_size_t)v[n].iov_len)
 
731
# else
 
732
          /*
 
733
           * Sun C however defines this as size_t which is unsigned
 
734
           * 
 
735
           */
 
736
        while (n < *nelts && len >= v[n].iov_len)
 
737
# endif /* !__GNUC__ */
 
738
#else
 
739
          /*
 
740
           * Hopefully everything else does this
 
741
           * (this was the default for years)
 
742
           */
 
743
        while (n < *nelts && len >= v[n].iov_len)
 
744
#endif
717
745
            len -= v[n++].iov_len;
718
746
 
719
747
        if (n == *nelts) {
743
771
}
744
772
 
745
773
 
746
 
APREQ_DECLARE(apr_status_t) apreq_brigade_fwrite(apr_file_t *f,
747
 
                                                 apr_off_t *wlen,
748
 
                                                 apr_bucket_brigade *bb)
749
 
{
750
 
    struct iovec v[APREQ_DEFAULT_NELTS];
751
 
    apr_status_t s;
752
 
    apr_bucket *e;
753
 
    int n = 0;
754
 
    *wlen = 0;
755
 
 
756
 
    for (e = APR_BRIGADE_FIRST(bb); e != APR_BRIGADE_SENTINEL(bb);
757
 
         e = APR_BUCKET_NEXT(e))
758
 
    {
759
 
        apr_size_t len;
760
 
        if (n == APREQ_DEFAULT_NELTS) {
761
 
            s = apreq_fwritev(f, v, &n, &len);
762
 
            if (s != APR_SUCCESS)
763
 
                return s;
764
 
            *wlen += len;
765
 
        }
766
 
        s = apr_bucket_read(e, (const char **)&(v[n].iov_base),
767
 
                            &len, APR_BLOCK_READ);
768
 
        if (s != APR_SUCCESS)
769
 
            return s;
770
 
 
771
 
        v[n++].iov_len = len;
772
 
    }
773
 
 
774
 
    while (n > 0) {
775
 
        apr_size_t len;
776
 
        s = apreq_fwritev(f, v, &n, &len);
777
 
        if (s != APR_SUCCESS)
778
 
            return s;
779
 
        *wlen += len;
780
 
    }
781
 
    return APR_SUCCESS;
782
 
}
783
774
 
784
775
 
785
776
struct cleanup_data {
832
823
 
833
824
    /* NO APR_DELONCLOSE! see comment above */
834
825
    flag = APR_CREATE | APR_READ | APR_WRITE | APR_EXCL | APR_BINARY;
835
 
    /* Win32 needs the following to remove temp files.
836
 
     * XXX: figure out why the APR_SHARELOCK flag works;
837
 
     * a grep through the httpd sources seems to indicate
838
 
     * it's only used in sdbm files??
839
 
    */
840
 
#ifdef WIN32
841
 
    flag |= APR_FILE_NOCLEANUP | APR_SHARELOCK;
842
 
#endif
 
826
 
843
827
    rc = apr_file_mktemp(fp, tmpl, flag, pool);
844
828
 
845
829
    if (rc == APR_SUCCESS) {
1125
1109
    return s;
1126
1110
}
1127
1111
 
 
1112
APREQ_DECLARE(apr_status_t) apreq_brigade_fwrite(apr_file_t *f,
 
1113
                                                 apr_off_t *wlen,
 
1114
                                                 apr_bucket_brigade *bb)
 
1115
{
 
1116
    struct iovec v[APREQ_DEFAULT_NELTS];
 
1117
    apr_status_t s;
 
1118
    apr_bucket *e, *first;
 
1119
    int n = 0;
 
1120
    apr_bucket_brigade *tmp = bb;
 
1121
    *wlen = 0;
 
1122
 
 
1123
    if (BUCKET_IS_SPOOL(APR_BRIGADE_LAST(bb))) {
 
1124
        tmp = apr_brigade_create(bb->p, bb->bucket_alloc);
 
1125
 
 
1126
        s = apreq_brigade_copy(tmp, bb);
 
1127
        if (s != APR_SUCCESS)
 
1128
            return s;
 
1129
    }
 
1130
 
 
1131
    for (e = APR_BRIGADE_FIRST(tmp); e != APR_BRIGADE_SENTINEL(tmp);
 
1132
         e = APR_BUCKET_NEXT(e))
 
1133
    {
 
1134
        apr_size_t len;
 
1135
        if (n == APREQ_DEFAULT_NELTS) {
 
1136
            s = apreq_fwritev(f, v, &n, &len);
 
1137
            if (s != APR_SUCCESS)
 
1138
                return s;
 
1139
 
 
1140
            if (tmp != bb) {
 
1141
                while ((first = APR_BRIGADE_FIRST(tmp)) != e)
 
1142
                    apr_bucket_delete(first);
 
1143
            }
 
1144
 
 
1145
            *wlen += len;
 
1146
        }
 
1147
        s = apr_bucket_read(e, (const char **)&(v[n].iov_base),
 
1148
                            &len, APR_BLOCK_READ);
 
1149
        if (s != APR_SUCCESS)
 
1150
            return s;
 
1151
 
 
1152
        v[n++].iov_len = len;
 
1153
    }
 
1154
 
 
1155
    while (n > 0) {
 
1156
        apr_size_t len;
 
1157
        s = apreq_fwritev(f, v, &n, &len);
 
1158
        if (s != APR_SUCCESS)
 
1159
            return s;
 
1160
        *wlen += len;
 
1161
 
 
1162
        if (tmp != bb) {
 
1163
            while ((first = APR_BRIGADE_FIRST(tmp)) != e)
 
1164
                apr_bucket_delete(first);
 
1165
        }
 
1166
    }
 
1167
    return APR_SUCCESS;
 
1168
}