📄 ra_serf.h
字号:
*/ svn_ra_serf__request_body_delegate_t body_delegate; void *body_delegate_baton; /* The connection and session to be used for this request. */ svn_ra_serf__connection_t *conn; svn_ra_serf__session_t *session;} svn_ra_serf__handler_t;/* * Helper function to queue a request in the @a handler's connection. */serf_request_t*svn_ra_serf__request_create(svn_ra_serf__handler_t *handler);/* XML helper callbacks. */typedef struct svn_ra_serf__xml_state_t { /* A numeric value that represents the current state in parsing. * * Value 0 is reserved for use as the default state. */ int current_state; /* Private pointer set by the parsing code. */ void *private; /* Allocations should be made in this pool to match the lifetime of the * state. */ apr_pool_t *pool; /* The currently-declared namespace for this state. */ svn_ra_serf__ns_t *ns_list; /* Our previous states. */ struct svn_ra_serf__xml_state_t *prev;} svn_ra_serf__xml_state_t;/* Forward declaration of the XML parser structure. */typedef struct svn_ra_serf__xml_parser_t svn_ra_serf__xml_parser_t;/* Callback invoked with @a baton by our XML @a parser when an element with * the @a name containing @a attrs is opened. */typedef svn_error_t *(*svn_ra_serf__xml_start_element_t)(svn_ra_serf__xml_parser_t *parser, void *baton, svn_ra_serf__dav_props_t name, const char **attrs);/* Callback invoked with @a baton by our XML @a parser when an element with * the @a name is closed. */typedef svn_error_t *(*svn_ra_serf__xml_end_element_t)(svn_ra_serf__xml_parser_t *parser, void *baton, svn_ra_serf__dav_props_t name);/* Callback invoked with @a baton by our XML @a parser when a CDATA portion * of @a data with size @a len is encountered. * * This may be invoked multiple times for the same tag. * * @see svn_ra_serf__expand_string */typedef svn_error_t *(*svn_ra_serf__xml_cdata_chunk_handler_t)(svn_ra_serf__xml_parser_t *parser, void *baton, const char *data, apr_size_t len);/* * Helper structure associated with handle_xml_parser handler that will * specify how an XML response will be processed. */struct svn_ra_serf__xml_parser_t { /* Temporary allocations should be made in this pool. */ apr_pool_t *pool; /* Caller-specific data passed to the start, end, cdata callbacks. */ void *user_data; /* Callback invoked when a tag is opened. */ svn_ra_serf__xml_start_element_t start; /* Callback invoked when a tag is closed. */ svn_ra_serf__xml_end_element_t end; /* Callback invoked when a cdata chunk is received. */ svn_ra_serf__xml_cdata_chunk_handler_t cdata; /* Our associated expat-based XML parser. */ XML_Parser xmlp; /* Our current state. */ svn_ra_serf__xml_state_t *state; /* Our previously used states (will be reused). */ svn_ra_serf__xml_state_t *free_state; /* If non-NULL, the status code of the response will be stored here. * * If this is NULL and an error is received, an abort will be triggered. */ int *status_code; /* If non-NULL, this value will be set to TRUE when the response is * completed. */ svn_boolean_t *done; /* If non-NULL, when this parser completes, it will add done_item to * the list. */ svn_ra_serf__list_t **done_list; /* A pointer to the item that will be inserted into the list upon * completeion. */ svn_ra_serf__list_t *done_item; /* If this flag is TRUE, errors during parsing will be ignored. * * This is mainly used when we are processing an error XML response to * avoid infinite loops. */ svn_boolean_t ignore_errors; /* If an error occurred, this value will be non-NULL. */ svn_error_t *error;};/* * Parses a server-side error message into a local Subversion error. */typedef struct { /* Our local representation of the error. */ svn_error_t *error; /* Have we checked to see if there's an XML error in this response? */ svn_boolean_t init; /* Was there an XML error response? */ svn_boolean_t has_xml_response; /* Are we done with the response? */ svn_boolean_t done; /* Have we seen an error tag? */ svn_boolean_t in_error; /* Should we be collecting the XML cdata for the error message? */ svn_boolean_t collect_message; /* XML parser and namespace used to parse the remote response */ svn_ra_serf__xml_parser_t parser; /* The length of the error message we received. */ apr_size_t message_len;} svn_ra_serf__server_error_t;/* A simple request context that can be passed to handle_status_only. */typedef struct { /* The HTTP status code of the response */ int status; /* The HTTP status line of the response */ const char *reason; /* This value is set to TRUE when the response is completed. */ svn_boolean_t done; /* If an error occurred, this value will be initialized. */ svn_ra_serf__server_error_t server_error;} svn_ra_serf__simple_request_context_t;/* * Serf handler for @a request / @a response pair that takes in a * @a baton (@see svn_ra_serf__simple_request_context_t). * * Temporary allocations are made in @a pool. */apr_status_tsvn_ra_serf__handle_status_only(serf_request_t *request, serf_bucket_t *response, void *baton, apr_pool_t *pool);/* * Handler that discards the entire @a response body associated with a * @a request. * * If @a baton is a svn_ra_serf__server_error_t (i.e. non-NULL) and an * error is detected, it will be populated for later detection. * * All temporary allocations will be made in a @a pool. */apr_status_tsvn_ra_serf__handle_discard_body(serf_request_t *request, serf_bucket_t *response, void *baton, apr_pool_t *pool);/* * Handler that retrieves the embedded XML error response from the * the @a response body associated with a @a request. * * All temporary allocations will be made in a @a pool. */svn_error_t *svn_ra_serf__handle_server_error(serf_request_t *request, serf_bucket_t *response, apr_pool_t *pool);/* * This function will feed the RESPONSE body into XMLP. When parsing is * completed (i.e. an EOF is received), *DONE is set to TRUE. * * If an error occurs during processing RESP_ERR is invoked with the * RESP_ERR_BATON. * * Temporary allocations are made in POOL. */apr_status_tsvn_ra_serf__handle_xml_parser(serf_request_t *request, serf_bucket_t *response, void *handler_baton, apr_pool_t *pool);/** XML helper functions. **//* * Advance the internal XML @a parser to the @a state. */voidsvn_ra_serf__xml_push_state(svn_ra_serf__xml_parser_t *parser, int state);/* * Return to the previous internal XML @a parser state. */voidsvn_ra_serf__xml_pop_state(svn_ra_serf__xml_parser_t *parser);/* * Add the appropriate serf buckets to @a agg_bucket represented by * the XML * @a tag and @a value. * * The bucket will be allocated from @a bkt_alloc. */voidsvn_ra_serf__add_tag_buckets(serf_bucket_t *agg_bucket, const char *tag, const char *value, serf_bucket_alloc_t *bkt_alloc);/* * Look up the @a attrs array for namespace definitions and add each one * to the @a ns_list of namespaces. * * New namespaces will be allocated in @a pool. */voidsvn_ra_serf__define_ns(svn_ra_serf__ns_t **ns_list, const char **attrs, apr_pool_t *pool);/* * Look up @a name in the @a ns_list list for previously declared namespace * definitions. * * @return @a svn_ra_serf__dav_props_t tuple representing the expanded name. */svn_ra_serf__dav_props_tsvn_ra_serf__expand_ns(svn_ra_serf__ns_t *ns_list, const char *name);/* * Look for @a attr_name in the @a attrs array and return its value. * * Returns NULL if no matching name is found. */const char *svn_ra_serf__find_attr(const char **attrs, const char *attr_name);/* * Expand the string represented by @a cur with a current size of @a * cur_len by appending @a new with a size of @a new_len. * * The reallocated string is made in @a pool. */voidsvn_ra_serf__expand_string(const char **cur, apr_size_t *cur_len, const char *new, apr_size_t new_len, apr_pool_t *pool);/** PROPFIND-related functions **//* Opaque structure representing PROPFINDs. */typedef struct svn_ra_serf__propfind_context_t svn_ra_serf__propfind_context_t;/* * Returns a flag representing whether the PROPFIND @a ctx is completed. */svn_boolean_tsvn_ra_serf__propfind_is_done(svn_ra_serf__propfind_context_t *ctx);/* * Returns the response status code of the PROPFIND @a ctx. */intsvn_ra_serf__propfind_status_code(svn_ra_serf__propfind_context_t *ctx);/* Our PROPFIND bucket */serf_bucket_t *svn_ra_serf__bucket_propfind_create(svn_ra_serf__connection_t *conn, const char *path, const char *label, const char *depth, const svn_ra_serf__dav_props_t *find_props, serf_bucket_alloc_t *allocator);/* * This function will deliver a PROP_CTX PROPFIND request in the SESS * serf context for the properties listed in LOOKUP_PROPS at URL for * DEPTH ("0","1","infinity"). * * This function will not block waiting for the response. Instead, the * caller is expected to call context_run and wait for the PROP_CTX->done * flag to be set. */svn_error_t *svn_ra_serf__deliver_props(svn_ra_serf__propfind_context_t **prop_ctx, apr_hash_t *prop_vals, svn_ra_serf__session_t *sess, svn_ra_serf__connection_t *conn, const char *url, svn_revnum_t rev, const char *depth, const svn_ra_serf__dav_props_t *lookup_props,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -