~ubuntu-branches/ubuntu/trusty/serf/trusty-security

« back to all changes in this revision

Viewing changes to serf.h

  • Committer: Bazaar Package Importer
  • Author(s): Peter Samuelson
  • Date: 2011-06-27 18:09:28 UTC
  • mfrom: (1.2.5 upstream)
  • mto: (3.3.1 sid)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: james.westby@ubuntu.com-20110627180928-ybwzd3hmx82nu3ir
Tags: 1.0.0~0+svn1514-1
* New upstream snapshot.
  - patches/abi-0.x: Remove as obsolete.
  - patches/kqueue: Forward-port.
  - Bump ABI: libserf0.7{,-dbg} -> libserf1{,-dbg}
  - patches/ip6-localhost: New patch: temporary (I hope) workaround for
    IPv4 / IPv6 confusion in testsuite.
* Implement Multi-Arch: same.
* libserf-dev Conflicts: libserf-0-0-dev, not Breaks.  Thanks, lintian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
 * could be processed on the other side.
70
70
 */
71
71
#define SERF_ERROR_REQUEST_LOST (APR_OS_START_USERERR + SERF_ERROR_RANGE + 2)
 
72
/* This code is for when the connection is blocked - we can not proceed
 
73
 * until something happens - generally due to SSL negotiation-like behavior
 
74
 * where a write() is blocked until a read() is processed.
 
75
 */
 
76
#define SERF_ERROR_WAIT_CONN (APR_OS_START_USERERR + SERF_ERROR_RANGE + 3)
 
77
/* This code is for when something went wrong during deflating compressed
 
78
 * data e.g. a CRC error. */
 
79
#define SERF_ERROR_DECOMPRESSION_FAILED (APR_OS_START_USERERR + \
 
80
                                             SERF_ERROR_RANGE + 4)
 
81
/* This code is for when a response received from a http server is not in
 
82
 * http-compliant syntax. */
 
83
#define SERF_ERROR_BAD_HTTP_RESPONSE (APR_OS_START_USERERR + \
 
84
                                             SERF_ERROR_RANGE + 5)
72
85
 
73
86
/* General authentication related errors */
74
87
#define SERF_ERROR_AUTHN_FAILED (APR_OS_START_USERERR + SERF_ERROR_RANGE + 90)
83
96
#define SERF_ERROR_AUTHN_INITALIZATION_FAILED (APR_OS_START_USERERR +\
84
97
    SERF_ERROR_RANGE + 93)
85
98
 
 
99
/* This macro groups errors potentially raised when reading a http response.  */
 
100
#define SERF_BAD_RESPONSE_ERROR(status) ((status) \
 
101
    && ((SERF_ERROR_DECOMPRESSION_FAILED == (status)) \
 
102
        ||(SERF_ERROR_BAD_HTTP_RESPONSE == (status))))
 
103
 
 
104
/**
 
105
 * Return a string that describes the specified error code.
 
106
 *
 
107
 * If the error code is not one of the above Serf error codes, then
 
108
 * NULL will be returned.
 
109
 *
 
110
 * Note regarding lifetime: the string is a statically-allocated constant
 
111
 */
 
112
const char *serf_error_string(apr_status_t errcode);
 
113
 
 
114
 
86
115
/**
87
116
 * Create a new context for serf operations.
88
117
 *
813
842
     */
814
843
    void (*destroy)(serf_bucket_t *bucket);
815
844
 
816
 
    /**
817
 
     * Save the current state of the @a bucket for later retrieval and return
818
 
     * APR_SUCCESS. A previously set snapshot will be cleared.
819
 
     * In case of error, the bucket should be considered invalid.
820
 
     */
821
 
    apr_status_t (*snapshot)(serf_bucket_t *bucket);
822
 
 
823
 
    /**
824
 
     * Restore the state of the @a bucket to the state set in the last
825
 
     * snapshot and returns APR_SUCCESS. If no snapshot was set, the bucket's
826
 
     * state is unchanged and APR_SUCCESS is returned.
827
 
     * In case of error, the bucket should be considered invalid.
828
 
     */
829
 
    apr_status_t (*restore_snapshot)(serf_bucket_t *bucket);
830
 
 
831
 
    /**
832
 
     * Test if a snapshot is set. Returns 0 if no snapshot was set, a non-0
833
 
     * value if there is a snapshot set.
834
 
     */
835
 
    int (*is_snapshot_set)(serf_bucket_t *bucket);
836
 
 
837
845
    /* ### apr buckets have 'copy', 'split', and 'setaside' functions.
838
846
       ### not sure whether those will be needed in this bucket model.
839
847
    */
878
886
#define serf_bucket_read_bucket(b,t) ((b)->type->read_bucket(b,t))
879
887
#define serf_bucket_peek(b,d,l) ((b)->type->peek(b,d,l))
880
888
#define serf_bucket_destroy(b) ((b)->type->destroy(b))
881
 
#define serf_bucket_snapshot(b) ((b)->type->snapshot(b))
882
 
#define serf_bucket_restore_snapshot(b) ((b)->type->restore_snapshot(b))
883
 
#define serf_bucket_is_snapshot_set(b) ((b)->type->is_snapshot_set(b))
884
889
 
885
890
/**
886
891
 * Check whether a real error occurred. Note that bucket read functions
889
894
 */
890
895
#define SERF_BUCKET_READ_ERROR(status) ((status) \
891
896
                                        && !APR_STATUS_IS_EOF(status) \
892
 
                                        && !APR_STATUS_IS_EAGAIN(status))
 
897
                                        && !APR_STATUS_IS_EAGAIN(status) \
 
898
                                        && (SERF_ERROR_WAIT_CONN != status))
893
899
 
894
900
 
895
901
struct serf_bucket_t {
1023
1029
    serf_bucket_alloc_t *allocator);
1024
1030
 
1025
1031
/* Version info */
1026
 
#define SERF_MAJOR_VERSION 0
1027
 
#define SERF_MINOR_VERSION 7
1028
 
#define SERF_PATCH_VERSION 2
 
1032
#define SERF_MAJOR_VERSION 1
 
1033
#define SERF_MINOR_VERSION 0
 
1034
#define SERF_PATCH_VERSION 0
1029
1035
 
1030
1036
/* Version number string */
1031
1037
#define SERF_VERSION_STRING APR_STRINGIFY(SERF_MAJOR_VERSION) "." \