| ne_207.h | | ne_207.h | |
| | | | |
| skipping to change at line 57 | | skipping to change at line 57 | |
| * multiple times before end_prop, start/end_propstat multiple times | | * multiple times before end_prop, start/end_propstat multiple times | |
| * before an end_response, start/end_response multiple times. | | * before an end_response, start/end_response multiple times. | |
| */ | | */ | |
| | | | |
| /* TODO: do we need to pass userdata to ALL of these? We could get away wit
h | | /* TODO: do we need to pass userdata to ALL of these? We could get away wit
h | |
| * only passing the userdata to the start_'s and relying on the caller | | * only passing the userdata to the start_'s and relying on the caller | |
| * to send it through as the _start return value if they need it. */ | | * to send it through as the _start return value if they need it. */ | |
| | | | |
| typedef void *(*ne_207_start_response)(void *userdata, const char *href); | | typedef void *(*ne_207_start_response)(void *userdata, const char *href); | |
| typedef void (*ne_207_end_response)( | | typedef void (*ne_207_end_response)( | |
|
| void *userdata, void *response, const char *status_line, | | void *userdata, void *response, const ne_status *status, | |
| const ne_status *status, const char *description); | | const char *description); | |
| | | | |
| typedef void *(*ne_207_start_propstat)(void *userdata, void *response); | | typedef void *(*ne_207_start_propstat)(void *userdata, void *response); | |
| typedef void (*ne_207_end_propstat)( | | typedef void (*ne_207_end_propstat)( | |
|
| void *userdata, void *propstat, const char *status_line, | | void *userdata, void *propstat, | |
| const ne_status *status, const char *description); | | const ne_status *status, const char *description); | |
| | | | |
| /* Create a 207 parser */ | | /* Create a 207 parser */ | |
| | | | |
| ne_207_parser *ne_207_create(ne_xml_parser *parser, void *userdata); | | ne_207_parser *ne_207_create(ne_xml_parser *parser, void *userdata); | |
| | | | |
| /* Set the callbacks for the parser */ | | /* Set the callbacks for the parser */ | |
| | | | |
| void ne_207_set_response_handlers( | | void ne_207_set_response_handlers( | |
| ne_207_parser *p, ne_207_start_response start, ne_207_end_response end)
; | | ne_207_parser *p, ne_207_start_response start, ne_207_end_response end)
; | |
| | | | |
End of changes. 2 change blocks. |
| 3 lines changed or deleted | | 3 lines changed or added | |
|
| ne_basic.h | | ne_basic.h | |
| | | | |
| skipping to change at line 52 | | skipping to change at line 52 | |
| #define NE_DEPTH_ONE (1) | | #define NE_DEPTH_ONE (1) | |
| #define NE_DEPTH_INFINITE (2) | | #define NE_DEPTH_INFINITE (2) | |
| | | | |
| /* For ne_copy and ne_move: | | /* For ne_copy and ne_move: | |
| * | | * | |
| * If a resource exists at "dest" and overwrite is zero, the operation | | * If a resource exists at "dest" and overwrite is zero, the operation | |
| * will fail; if overwrite is non-zero, any existing resource will | | * will fail; if overwrite is non-zero, any existing resource will | |
| * be over-written. | | * be over-written. | |
| */ | | */ | |
| | | | |
|
| /* Copy resource from src to dest URIs. If src identifies a collection | | /* Copy resource from 'src to 'dest' paths. If 'src' identifies a | |
| * resource, depth may be NE_DEPTH_ZERO to request that the collection | | * collection resource, depth may be NE_DEPTH_ZERO to request that the | |
| * and its properties are to be copied, or NE_DEPTH_INFINITE to | | * collection and its properties are to be copied, or | |
| * request that the collection and its contents are to be copied. */ | | * NE_DEPTH_INFINITE to request that the collection and its contents | |
| | | * are to be copied. */ | |
| int ne_copy(ne_session *sess, int overwrite, int depth, | | int ne_copy(ne_session *sess, int overwrite, int depth, | |
| const char *src, const char *dest); | | const char *src, const char *dest); | |
| | | | |
|
| /* Move resource from src to dest URI. */ | | /* Move resource from 'src' to dest 'path'. */ | |
| int ne_move(ne_session *sess, int overwrite, | | int ne_move(ne_session *sess, int overwrite, | |
| const char *src, const char *dest); | | const char *src, const char *dest); | |
| | | | |
|
| /* Delete resource at uri. */ | | /* Delete resource at 'path'. */ | |
| int ne_delete(ne_session *sess, const char *uri); | | int ne_delete(ne_session *sess, const char *path); | |
| /* Create a collection at uri, which MUST have a trailing slash. */ | | /* Create a collection at 'path', which MUST have a trailing slash. */ | |
| int ne_mkcol(ne_session *sess, const char *uri); | | int ne_mkcol(ne_session *sess, const char *path); | |
| | | | |
| /* Adds a Depth: header to a request */ | | /* Adds a Depth: header to a request */ | |
| void ne_add_depth_header(ne_request *req, int depth); | | void ne_add_depth_header(ne_request *req, int depth); | |
| | | | |
| #endif /* NEON_NODAV */ | | #endif /* NEON_NODAV */ | |
| | | | |
|
| /* PUT resource at uri as above, only if it has not been modified | | /* PUT resource at location as above, only if it has not been modified | |
| * since given modtime. If server is HTTP/1.1, uses If-Unmodified-Since | | * since given modtime. If server is HTTP/1.1, uses If-Unmodified-Since | |
| * header; guaranteed failure if resource is modified after 'modtime'. | | * header; guaranteed failure if resource is modified after 'modtime'. | |
| * If server is HTTP/1.0, HEAD's the resource first to fetch current | | * If server is HTTP/1.0, HEAD's the resource first to fetch current | |
| * modtime; race condition if resource is modified between HEAD and PUT. | | * modtime; race condition if resource is modified between HEAD and PUT. | |
| */ | | */ | |
| int ne_put_if_unmodified(ne_session *sess, | | int ne_put_if_unmodified(ne_session *sess, | |
|
| const char *uri, int fd, time_t modtime); | | const char *path, int fd, time_t modtime); | |
| | | | |
| /* GET resource at uri, passing response body blocks to 'reader' */ | | | |
| int ne_read_file(ne_session *sess, const char *uri, | | | |
| ne_block_reader reader, void *userdata); | | | |
| | | | |
|
| /* Retrieve modification time of resource at uri, place in *modtime. | | /* Retrieve modification time of resource at location 'path', place in | |
| * (uses HEAD) */ | | * *modtime. (uses HEAD) */ | |
| int ne_getmodtime(ne_session *sess, const char *uri, time_t *modtime); | | int ne_getmodtime(ne_session *sess, const char *path, time_t *modtime); | |
| | | | |
| typedef struct { | | typedef struct { | |
| const char *type, *subtype; | | const char *type, *subtype; | |
| const char *charset; | | const char *charset; | |
| char *value; | | char *value; | |
| } ne_content_type; | | } ne_content_type; | |
| | | | |
| /* Sets (*ne_content_type)userdata appropriately. | | /* Sets (*ne_content_type)userdata appropriately. | |
| * Caller must free ->value after use */ | | * Caller must free ->value after use */ | |
| void ne_content_type_handler(void *userdata, const char *value); | | void ne_content_type_handler(void *userdata, const char *value); | |
| | | | |
| /* Server capabilities: */ | | /* Server capabilities: */ | |
| typedef struct { | | typedef struct { | |
| unsigned int dav_class1; /* True if Class 1 WebDAV server */ | | unsigned int dav_class1; /* True if Class 1 WebDAV server */ | |
| unsigned int dav_class2; /* True if Class 2 WebDAV server */ | | unsigned int dav_class2; /* True if Class 2 WebDAV server */ | |
| unsigned int dav_executable; /* True if supports the 'executable' | | unsigned int dav_executable; /* True if supports the 'executable' | |
| * property a. la. mod_dav */ | | * property a. la. mod_dav */ | |
| } ne_server_capabilities; | | } ne_server_capabilities; | |
| | | | |
|
| /* Determines server capabilities (using OPTIONS). | | /* Determines server capabilities (using OPTIONS). Pass 'path' as "*" | |
| * Pass uri="*" to determine proxy server capabilities if using | | * to determine proxy server capabilities if using a proxy server. */ | |
| * a proxy server. */ | | int ne_options(ne_session *sess, const char *path, | |
| int ne_options(ne_session *sess, const char *uri, | | | |
| ne_server_capabilities *caps); | | ne_server_capabilities *caps); | |
| | | | |
| /* Defines a range of bytes, starting at 'start' and ending | | /* Defines a range of bytes, starting at 'start' and ending | |
| * at 'end'. 'total' is the number of bytes in the range. | | * at 'end'. 'total' is the number of bytes in the range. | |
| */ | | */ | |
| typedef struct { | | typedef struct { | |
| off_t start, end, total; | | off_t start, end, total; | |
| } ne_content_range; | | } ne_content_range; | |
| | | | |
| /* Partial GET. range->start must be >= 0. range->total is ignored. | | /* Partial GET. range->start must be >= 0. range->total is ignored. | |
| | | | |
| skipping to change at line 134 | | skipping to change at line 130 | |
| * requested, and range->total and end are filled in on success. | | * requested, and range->total and end are filled in on success. | |
| * | | * | |
| * Otherwise, bytes from range->start to range->end are requested. | | * Otherwise, bytes from range->start to range->end are requested. | |
| * | | * | |
| * This will write to the CURRENT position of f; so if you want | | * This will write to the CURRENT position of f; so if you want | |
| * to do a resume download, use: | | * to do a resume download, use: | |
| * struct ne_content_range range; | | * struct ne_content_range range; | |
| * range.start = resume_from; | | * range.start = resume_from; | |
| * range.end = range.start + 999; (= 1000 bytes) | | * range.end = range.start + 999; (= 1000 bytes) | |
| * fseek(myfile, resume_from, SEEK_SET); | | * fseek(myfile, resume_from, SEEK_SET); | |
|
| * ne_get_range(sess, uri, &range, myfile); */ | | * ne_get_range(sess, path, &range, myfile); */ | |
| int ne_get_range(ne_session *sess, const char *uri, | | int ne_get_range(ne_session *sess, const char *path, | |
| ne_content_range *range, int fd); | | ne_content_range *range, int fd); | |
| | | | |
| /* Post using buffer as request-body: stream response into f */ | | /* Post using buffer as request-body: stream response into f */ | |
|
| int ne_post(ne_session *sess, const char *uri, int fd, const char *buffer); | | int ne_post(ne_session *sess, const char *path, int fd, const char *buffer)
; | |
| | | | |
| END_NEON_DECLS | | END_NEON_DECLS | |
| | | | |
| #endif /* NE_BASIC_H */ | | #endif /* NE_BASIC_H */ | |
| | | | |
End of changes. 9 change blocks. |
| 25 lines changed or deleted | | 21 lines changed or added | |
|
| ne_request.h | | ne_request.h | |
| | | | |
| skipping to change at line 211 | | skipping to change at line 211 | |
| | | | |
| /* Destroy memory associated with request pointer */ | | /* Destroy memory associated with request pointer */ | |
| void ne_request_destroy(ne_request *req); | | void ne_request_destroy(ne_request *req); | |
| | | | |
| /* "Caller-pulls" request interface. This is an ALTERNATIVE interface | | /* "Caller-pulls" request interface. This is an ALTERNATIVE interface | |
| * to ne_request_dispatch: either use that, or do all this yourself: | | * to ne_request_dispatch: either use that, or do all this yourself: | |
| * | | * | |
| * caller must call: | | * caller must call: | |
| * 1. ne_begin_request (fail if returns non-NE_OK) | | * 1. ne_begin_request (fail if returns non-NE_OK) | |
| * 2. while(ne_read_response_block(...) > 0) ... loop ...; | | * 2. while(ne_read_response_block(...) > 0) ... loop ...; | |
|
| | | * (fail if ne_read_response_block returns <0) | |
| * 3. ne_end_request | | * 3. ne_end_request | |
| * | | * | |
| * ne_end_request and ne_begin_request both return an NE_* code; if | | * ne_end_request and ne_begin_request both return an NE_* code; if | |
| * ne_end_request returns NE_RETRY, you must restart the loop from (1) | | * ne_end_request returns NE_RETRY, you must restart the loop from (1) | |
| * above. */ | | * above. */ | |
| int ne_begin_request(ne_request *req); | | int ne_begin_request(ne_request *req); | |
| int ne_end_request(ne_request *req); | | int ne_end_request(ne_request *req); | |
| | | | |
| /* Read a block of the response. buffer must be at least 128 bytes. | | /* Read a block of the response. buffer must be at least 128 bytes. | |
| * 'buflen' must be length of buffer. | | * 'buflen' must be length of buffer. | |
| | | | |
| skipping to change at line 234 | | skipping to change at line 235 | |
| * 0 - end of response | | * 0 - end of response | |
| * >0 - number of bytes read into buffer. | | * >0 - number of bytes read into buffer. | |
| */ | | */ | |
| ssize_t ne_read_response_block(ne_request *req, char *buffer, size_t buflen
); | | ssize_t ne_read_response_block(ne_request *req, char *buffer, size_t buflen
); | |
| | | | |
| /**** Request hooks handling *****/ | | /**** Request hooks handling *****/ | |
| | | | |
| typedef void (*ne_free_hooks)(void *cookie); | | typedef void (*ne_free_hooks)(void *cookie); | |
| | | | |
| /* Hook called when a create is created. */ | | /* Hook called when a create is created. */ | |
|
| typedef void (*ne_create_request_fn)(void *userdata, ne_request *req, | | typedef void (*ne_create_request_fn)(ne_request *req, void *userdata, | |
| const char *method, const char *path); | | const char *method, const char *path); | |
| void ne_hook_create_request(ne_session *sess, | | void ne_hook_create_request(ne_session *sess, | |
| ne_create_request_fn fn, void *userdata); | | ne_create_request_fn fn, void *userdata); | |
| | | | |
| /* Hook called before the request is sent. 'header' is the raw HTTP | | /* Hook called before the request is sent. 'header' is the raw HTTP | |
| * header before the trailing CRLF is added: add in more here. */ | | * header before the trailing CRLF is added: add in more here. */ | |
|
| typedef void (*ne_pre_send_fn)(void *userdata, ne_buffer *header); | | typedef void (*ne_pre_send_fn)(ne_request *req, void *userdata, | |
| | | ne_buffer *header); | |
| void ne_hook_pre_send(ne_session *sess, ne_pre_send_fn fn, void *userdata); | | void ne_hook_pre_send(ne_session *sess, ne_pre_send_fn fn, void *userdata); | |
| | | | |
| /* Hook called after the request is sent. May return: | | /* Hook called after the request is sent. May return: | |
| * NE_OK everything is okay | | * NE_OK everything is okay | |
| * NE_RETRY try sending the request again. | | * NE_RETRY try sending the request again. | |
| * anything else signifies an error, and the request is failed. The return | | * anything else signifies an error, and the request is failed. The return | |
| * code is passed back the _dispatch caller, so the session error must | | * code is passed back the _dispatch caller, so the session error must | |
| * also be set appropriately (ne_set_error). | | * also be set appropriately (ne_set_error). | |
| */ | | */ | |
|
| typedef int (*ne_post_send_fn)(void *userdata, const ne_status *status); | | typedef int (*ne_post_send_fn)(ne_request *req, void *userdata, | |
| | | const ne_status *status); | |
| void ne_hook_post_send(ne_session *sess, ne_post_send_fn fn, void *userdata
); | | void ne_hook_post_send(ne_session *sess, ne_post_send_fn fn, void *userdata
); | |
| | | | |
| /* Hook called when the function is destroyed. */ | | /* Hook called when the function is destroyed. */ | |
|
| typedef void (*ne_destroy_fn)(void *userdata); | | typedef void (*ne_destroy_req_fn)(ne_request *req, void *userdata); | |
| void ne_hook_destroy_request(ne_session *sess, | | void ne_hook_destroy_request(ne_session *sess, | |
|
| ne_destroy_fn fn, void *userdata); | | ne_destroy_req_fn fn, void *userdata); | |
| | | | |
|
| | | typedef void (*ne_destroy_sess_fn)(void *userdata); | |
| /* Hook called when the session is destroyed. */ | | /* Hook called when the session is destroyed. */ | |
| void ne_hook_destroy_session(ne_session *sess, | | void ne_hook_destroy_session(ne_session *sess, | |
|
| ne_destroy_fn fn, void *userdata); | | ne_destroy_sess_fn fn, void *userdata); | |
| | | | |
| /* Hook used to allow external access into hook processing. */ | | | |
| typedef void *(*ne_accessor_fn)(void *userdata); | | | |
| void ne_hook_session_accessor(ne_session *sess, const char *id, | | | |
| ne_accessor_fn, void *userdata); | | | |
| void ne_hook_request_accessor(ne_request *req, const char *id, | | | |
| ne_accessor_fn, void *userdata); | | | |
| | | | |
| /* an accessor which simply returns the userdata. */ | | | |
| void *ne_null_accessor(void *userdata); | | | |
| | | | |
| void *ne_session_hook_private(ne_session *sess, const char *id); | | | |
| | | | |
|
| void *ne_request_hook_private(ne_request *req, const char *id); | | /* Store an opaque context for the request, 'priv' is returned by a | |
| | | * call to ne_request_get_private with the same ID. */ | |
| | | void ne_set_request_private(ne_request *req, const char *id, void *priv); | |
| | | void *ne_get_request_private(ne_request *req, const char *id); | |
| | | | |
| END_NEON_DECLS | | END_NEON_DECLS | |
| | | | |
| #endif /* NE_REQUEST_H */ | | #endif /* NE_REQUEST_H */ | |
| | | | |
End of changes. 9 change blocks. |
| 19 lines changed or deleted | | 14 lines changed or added | |
|
| ne_session.h | | ne_session.h | |
| | | | |
| skipping to change at line 41 | | skipping to change at line 41 | |
| #include "ne_defs.h" | | #include "ne_defs.h" | |
| | | | |
| BEGIN_NEON_DECLS | | BEGIN_NEON_DECLS | |
| | | | |
| typedef struct ne_session_s ne_session; | | typedef struct ne_session_s ne_session; | |
| | | | |
| /* Create a session to the given server, using the given scheme. If | | /* Create a session to the given server, using the given scheme. If | |
| * "https" is passed as the scheme, SSL will be used to connect to the | | * "https" is passed as the scheme, SSL will be used to connect to the | |
| * server. */ | | * server. */ | |
| ne_session *ne_session_create(const char *scheme, | | ne_session *ne_session_create(const char *scheme, | |
|
| const char *hostname, int port); | | const char *hostname, unsigned int port); | |
| | | | |
| /* Finish an HTTP session */ | | /* Finish an HTTP session */ | |
| void ne_session_destroy(ne_session *sess); | | void ne_session_destroy(ne_session *sess); | |
| | | | |
| /* Prematurely force the connection to be closed for the given | | /* Prematurely force the connection to be closed for the given | |
| * session. */ | | * session. */ | |
| void ne_close_connection(ne_session *sess); | | void ne_close_connection(ne_session *sess); | |
| | | | |
| /* Set the proxy server to be used for the session. */ | | /* Set the proxy server to be used for the session. */ | |
|
| void ne_session_proxy(ne_session *sess, const char *hostname, int port); | | void ne_session_proxy(ne_session *sess, | |
| | | const char *hostname, unsigned int port); | |
| | | | |
| /* Set protocol options for session: | | /* Set protocol options for session: | |
| * expect100: Defaults to OFF | | * expect100: Defaults to OFF | |
| * persist: Defaults to ON | | * persist: Defaults to ON | |
| * | | * | |
| * expect100: When set, send the "Expect: 100-continue" request header | | * expect100: When set, send the "Expect: 100-continue" request header | |
| * with requests with bodies. | | * with requests with bodies. | |
| * | | * | |
| * persist: When set, use a persistent connection. (Generally, | | * persist: When set, use a persistent connection. (Generally, | |
| * you don't want to turn this off.) | | * you don't want to turn this off.) | |
| * */ | | * */ | |
| void ne_set_expect100(ne_session *sess, int use_expect100); | | void ne_set_expect100(ne_session *sess, int use_expect100); | |
| void ne_set_persist(ne_session *sess, int persist); | | void ne_set_persist(ne_session *sess, int persist); | |
| | | | |
| /* Set a progress callback for the session. */ | | /* Set a progress callback for the session. */ | |
| void ne_set_progress(ne_session *sess, | | void ne_set_progress(ne_session *sess, | |
| ne_progress progress, void *userdata); | | ne_progress progress, void *userdata); | |
| | | | |
|
| | | /* Store an opaque context for the session, 'priv' is returned by a | |
| | | * call to ne_session_get_private with the same ID. */ | |
| | | void ne_set_session_private(ne_session *sess, const char *id, void *priv); | |
| | | void *ne_get_session_private(ne_session *sess, const char *id); | |
| | | | |
| typedef enum { | | typedef enum { | |
| ne_conn_namelookup, /* lookup up hostname (info = hostname) */ | | ne_conn_namelookup, /* lookup up hostname (info = hostname) */ | |
| ne_conn_connecting, /* connecting to host (info = hostname) */ | | ne_conn_connecting, /* connecting to host (info = hostname) */ | |
| ne_conn_connected, /* connected to host (info = hostname) */ | | ne_conn_connected, /* connected to host (info = hostname) */ | |
| ne_conn_secure /* connection now secure (info = crypto level) */ | | ne_conn_secure /* connection now secure (info = crypto level) */ | |
| } ne_conn_status; | | } ne_conn_status; | |
| | | | |
| typedef void (*ne_notify_status)(void *userdata, | | typedef void (*ne_notify_status)(void *userdata, | |
| ne_conn_status status, | | ne_conn_status status, | |
| const char *info); | | const char *info); | |
| | | | |
End of changes. 3 change blocks. |
| 2 lines changed or deleted | | 8 lines changed or added | |
|
| ne_socket.h | | ne_socket.h | |
| | | | |
| skipping to change at line 49 | | skipping to change at line 49 | |
| | | | |
| #include "ne_defs.h" | | #include "ne_defs.h" | |
| | | | |
| BEGIN_NEON_DECLS | | BEGIN_NEON_DECLS | |
| | | | |
| /* define ssize_t for Win32 */ | | /* define ssize_t for Win32 */ | |
| #if defined(WIN32) && !defined(ssize_t) | | #if defined(WIN32) && !defined(ssize_t) | |
| #define ssize_t int | | #define ssize_t int | |
| #endif | | #endif | |
| | | | |
|
| #define NE_SOCK_ERROR -1 | | #define NE_SOCK_ERROR (-1) | |
| /* Read/Write timed out */ | | /* Read/Write timed out */ | |
|
| #define NE_SOCK_TIMEOUT -2 | | #define NE_SOCK_TIMEOUT (-2) | |
| /* Socket was closed */ | | /* Socket was closed */ | |
|
| #define NE_SOCK_CLOSED -3 | | #define NE_SOCK_CLOSED (-3) | |
| | | /* Connection was reset (e.g. server crashed) */ | |
| | | #define NE_SOCK_RESET (-4) | |
| | | | |
| typedef struct ne_socket_s ne_socket; | | typedef struct ne_socket_s ne_socket; | |
| | | | |
| typedef void (*ne_block_reader) ( | | typedef void (*ne_block_reader) ( | |
| void *userdata, const char *buf, size_t len); | | void *userdata, const char *buf, size_t len); | |
| | | | |
| typedef void (*ne_progress)(void *userdata, off_t progress, off_t total); | | typedef void (*ne_progress)(void *userdata, off_t progress, off_t total); | |
| | | | |
| void ne_register_progress(ne_socket *sock, ne_progress cb, void *userdata); | | void ne_register_progress(ne_socket *sock, ne_progress cb, void *userdata); | |
| | | | |
| /* While neon itself doesn't require per-process global | | /* While neon itself doesn't require per-process global | |
| * initialization, some platforms do, and so does the OpenSSL | | * initialization, some platforms do, and so does the OpenSSL | |
| * library. */ | | * library. */ | |
| int ne_sock_init(void); | | int ne_sock_init(void); | |
| | | | |
| /* Shutdown any underlying libraries. */ | | /* Shutdown any underlying libraries. */ | |
| void ne_sock_exit(void); | | void ne_sock_exit(void); | |
| | | | |
|
| /* ne_read is read() with a timeout | | /* ne_sock_read reads up to 'count' bytes into 'buffer'. | |
| * Returns: | | * Returns: | |
| * NE_SOCK_* on error, | | * NE_SOCK_* on error, | |
|
| * 0 on no data to read (due to EOF), | | | |
| * >0 length of data read into buffer. | | * >0 length of data read into buffer. | |
| */ | | */ | |
| ssize_t ne_sock_read(ne_socket *sock, char *buffer, size_t count); | | ssize_t ne_sock_read(ne_socket *sock, char *buffer, size_t count); | |
| | | | |
|
| /* ne_peek is recv() with a timeout | | /* ne_sock_peek reads up to 'count' bytes into 'buffer', but the data | |
| | | * will still be returned on a subsequent call to ne_sock_read or | |
| | | * ne_sock_peek. | |
| * Returns: | | * Returns: | |
| * NE_SOCK_* on error, | | * NE_SOCK_* on error, | |
|
| * 0 on no data to read (due to EOF), | | | |
| * >0 length of data read into buffer. | | * >0 length of data read into buffer. | |
| */ | | */ | |
| ssize_t ne_sock_peek(ne_socket *sock, char *buffer, size_t count); | | ssize_t ne_sock_peek(ne_socket *sock, char *buffer, size_t count); | |
| | | | |
| /* Block for up to 'n' seconds until data becomes available for reading | | /* Block for up to 'n' seconds until data becomes available for reading | |
| * on the socket. Returns: | | * on the socket. Returns: | |
| * NE_SOCK_* on error, | | * NE_SOCK_* on error, | |
| * NE_SOCK_TIMEOUT if no data arrives in 'n' seconds. | | * NE_SOCK_TIMEOUT if no data arrives in 'n' seconds. | |
| * 0 if data arrived on the socket. | | * 0 if data arrived on the socket. | |
| */ | | */ | |
| int ne_sock_block(ne_socket *sock, int n); | | int ne_sock_block(ne_socket *sock, int n); | |
| | | | |
|
| /* Sends the given block of data down the ne_socket. Returns zero on | | /* Writes 'count' bytes of 'data' to the socket. | |
| * success, NE_SOCK_* on error. */ | | * Returns 0 on success, NE_SOCK_* on error. */ | |
| int ne_sock_fullwrite(ne_socket *sock, const char *data, size_t length); | | int ne_sock_fullwrite(ne_socket *sock, const char *data, size_t count); | |
| | | | |
|
| /* Reads a line from given ne_socket */ | | /* Reads an LF-terminated line into 'buffer', and NUL-terminate it. | |
| ssize_t ne_sock_readline(ne_socket *sock, char *line, size_t len); | | * At most 'len' bytes are read (including the NUL terminator). | |
| | | * Returns: | |
| | | * NE_SOCK_* on error, | |
| | | * >0 number of bytes read (including NUL terminator) | |
| | | */ | |
| | | ssize_t ne_sock_readline(ne_socket *sock, char *buffer, size_t len); | |
| | | | |
| /* Read exactly 'len' bytes into buffer; returns 0 on success, SOCK_* | | /* Read exactly 'len' bytes into buffer; returns 0 on success, SOCK_* | |
| * on error. */ | | * on error. */ | |
|
| ssize_t ne_sock_fullread(ne_socket *sock, char *buffer, size_t buflen); | | ssize_t ne_sock_fullread(ne_socket *sock, char *buffer, size_t len); | |
| | | | |
|
| /* Creates and connects a ne_socket */ | | /* Create a socket connected to server at address 'host' on port | |
| ne_socket *ne_sock_connect(const struct in_addr host, | | * 'port'. Returns NULL if a connection could not be established. */ | |
| unsigned short int portnum); | | ne_socket *ne_sock_connect(const struct in_addr host, unsigned int port); | |
| | | | |
|
| /* Not as good as accept(2), missing parms 2+3. | | /* Accept a connection on listening socket 'fd'. */ | |
| * Addings parms 2+3 would probably mean passing socklen_t as an | | ne_socket *ne_sock_accept(int fd); | |
| * int then casting internally, since we don't really want to | | | |
| * autogenerate the header file to be correct for the build platform. | | | |
| */ | | | |
| ne_socket *ne_sock_accept(int listener); | | | |
| | | | |
|
| /* Returns the file descriptor used for the socket */ | | /* Returns the file descriptor used for socket 'sock'. */ | |
| int ne_sock_fd(const ne_socket *sock); | | int ne_sock_fd(const ne_socket *sock); | |
| | | | |
|
| /* Closes the socket and frees the ne_socket object. Returns non-zero | | /* Close the socket, and destroy the socket object. Returns non-zero | |
| * on error. */ | | * on error. */ | |
| int ne_sock_close(ne_socket *sock); | | int ne_sock_close(ne_socket *sock); | |
| | | | |
|
| | | /* Return current error string for socket. */ | |
| const char *ne_sock_error(const ne_socket *sock); | | const char *ne_sock_error(const ne_socket *sock); | |
| | | | |
| /* Set read timeout for socket. */ | | /* Set read timeout for socket. */ | |
| void ne_sock_read_timeout(ne_socket *sock, int timeout); | | void ne_sock_read_timeout(ne_socket *sock, int timeout); | |
| | | | |
| /* Do a name lookup on given hostname, writes the address into | | /* Do a name lookup on given hostname, writes the address into | |
| * given address buffer. Return -1 on failure. */ | | * given address buffer. Return -1 on failure. */ | |
| int ne_name_lookup(const char *hostname, struct in_addr *addr); | | int ne_name_lookup(const char *hostname, struct in_addr *addr); | |
| | | | |
| /* Returns the standard TCP port for the given service */ | | /* Returns the standard TCP port for the given service */ | |
| | | | |
| skipping to change at line 150 | | skipping to change at line 154 | |
| | | | |
| #ifdef NEON_SSL | | #ifdef NEON_SSL | |
| /* FIXME: this is a terribly disgusting API. */ | | /* FIXME: this is a terribly disgusting API. */ | |
| | | | |
| /* Enable SSL/TLS, using the given OpenSSL SSL context, and resuming | | /* Enable SSL/TLS, using the given OpenSSL SSL context, and resuming | |
| * the given session if sess is non-NULL. Returns non-zero if the SSL | | * the given session if sess is non-NULL. Returns non-zero if the SSL | |
| * negotiation fails. If out is non-NULL, *out is set to the SSL | | * negotiation fails. If out is non-NULL, *out is set to the SSL | |
| * connection structure from OpenSSL. */ | | * connection structure from OpenSSL. */ | |
| int ne_sock_use_ssl_os(ne_socket *sock, SSL_CTX *ctx, | | int ne_sock_use_ssl_os(ne_socket *sock, SSL_CTX *ctx, | |
| SSL_SESSION *sess, SSL **out, void *appdata); | | SSL_SESSION *sess, SSL **out, void *appdata); | |
|
| | | | |
| | | /* Enable SSL with an already-negotiated SSL socket. */ | |
| | | void ne_sock_switch_ssl(ne_socket *sock, SSL *ssl); | |
| | | | |
| #endif | | #endif | |
| | | | |
| END_NEON_DECLS | | END_NEON_DECLS | |
| | | | |
| #endif /* NE_SOCKET_H */ | | #endif /* NE_SOCKET_H */ | |
| | | | |
End of changes. 16 change blocks. |
| 24 lines changed or deleted | | 32 lines changed or added | |
|
| ne_string.h | | ne_string.h | |
| | | | |
| skipping to change at line 109 | | skipping to change at line 109 | |
| | | | |
| /* Grows the ne_buffer to a minimum size. */ | | /* Grows the ne_buffer to a minimum size. */ | |
| void ne_buffer_grow(ne_buffer *buf, size_t size); | | void ne_buffer_grow(ne_buffer *buf, size_t size); | |
| | | | |
| void ne_buffer_altered(ne_buffer *buf); | | void ne_buffer_altered(ne_buffer *buf); | |
| | | | |
| /* Destroys a buffer, WITHOUT freeing the data, and returns the | | /* Destroys a buffer, WITHOUT freeing the data, and returns the | |
| * data. */ | | * data. */ | |
| char *ne_buffer_finish(ne_buffer *buf); | | char *ne_buffer_finish(ne_buffer *buf); | |
| | | | |
|
| /* TODO: do these with stpcpy instead... more efficient, but means | | /* Thread-safe strerror() wrapper; place system error for errno value | |
| * bloat on non-GNU platforms. */ | | * 'errnum' in 'buffer', which is of length 'buflen'. */ | |
| | | void ne_strerror(int errnum, char *buffer, size_t buflen); | |
| /* NOTES: | | | |
| * - These abort() on malloc() returning NULL | | | |
| * - You will need to #include <string.h> / <strings.h> YOURSELF to | | | |
| * prototype strlen and strcat. | | | |
| */ | | | |
| | | | |
| #define CONCAT2(out, str1, str2) \ | | | |
| do { \ | | | |
| out = ne_malloc(strlen(str1) + strlen(str2) + 1); \ | | | |
| strcpy(out, str1); \ | | | |
| strcat(out, str2); \ | | | |
| } while (0) | | | |
| | | | |
| #define CONCAT3(out, str1, str2, str3) \ | | | |
| do { \ | | | |
| out = ne_malloc(strlen(str1) + strlen(str2) + strlen(str3) + 1); \ | | | |
| strcpy(out, str1); \ | | | |
| strcat(out, str2); \ | | | |
| strcat(out, str3); \ | | | |
| } while (0) | | | |
| | | | |
|
| #define CONCAT4(out, str1, str2, str3, str4) \ | | /* Return malloc-allocated concatenation of all NUL-terminated string | |
| do { \ | | * arguments, up to a terminating NULL. */ | |
| out = ne_malloc(strlen(str1) + strlen(str2) \ | | char *ne_concat(const char *str, ...); | |
| + strlen(str3) + strlen(str4) + 1); \ | | | |
| strcpy(out, str1); \ | | | |
| strcat(out, str2); \ | | | |
| strcat(out, str3); \ | | | |
| strcat(out, str4); \ | | | |
| } while (0) | | | |
| | | | |
| #define NE_ASC2HEX(x) (((x) <= '9') ? ((x) - '0') : (tolower((x)) + 10 - 'a
')) | | #define NE_ASC2HEX(x) (((x) <= '9') ? ((x) - '0') : (tolower((x)) + 10 - 'a
')) | |
| #define NE_HEX2ASC(x) ((x) > 9 ? ((x) - 10 + 'a') : ((x) + '0')) | | #define NE_HEX2ASC(x) ((x) > 9 ? ((x) - 10 + 'a') : ((x) + '0')) | |
| | | | |
| END_NEON_DECLS | | END_NEON_DECLS | |
| | | | |
| #endif /* NE_STRING_H */ | | #endif /* NE_STRING_H */ | |
| | | | |
End of changes. 2 change blocks. |
| 32 lines changed or deleted | | 6 lines changed or added | |
|
| ne_uri.h | | ne_uri.h | |
| | | | |
| skipping to change at line 51 | | skipping to change at line 51 | |
| /* Returns strcmp-like value giving comparison between p1 and p2, | | /* Returns strcmp-like value giving comparison between p1 and p2, | |
| * ignoring trailing-slashes. */ | | * ignoring trailing-slashes. */ | |
| int ne_path_compare(const char *p1, const char *p2); | | int ne_path_compare(const char *p1, const char *p2); | |
| | | | |
| /* Returns non-zero if child is a child of parent */ | | /* Returns non-zero if child is a child of parent */ | |
| int ne_path_childof(const char *parent, const char *child); | | int ne_path_childof(const char *parent, const char *child); | |
| | | | |
| /* Returns non-zero if path has a trailing slash character */ | | /* Returns non-zero if path has a trailing slash character */ | |
| int ne_path_has_trailing_slash(const char *path); | | int ne_path_has_trailing_slash(const char *path); | |
| | | | |
|
| /* Return the default port for the given scheme. */ | | /* Return the default port for the given scheme, or 0 if none is | |
| int ne_uri_defaultport(const char *scheme); | | * known. */ | |
| | | unsigned int ne_uri_defaultport(const char *scheme); | |
| | | | |
| typedef struct { | | typedef struct { | |
| char *scheme; | | char *scheme; | |
| char *host; | | char *host; | |
|
| int port; | | unsigned int port; | |
| char *path; | | char *path; | |
| char *authinfo; | | char *authinfo; | |
| } ne_uri; | | } ne_uri; | |
| | | | |
| /* Parse absoluteURI 'uri' and place parsed segments in *parsed. | | /* Parse absoluteURI 'uri' and place parsed segments in *parsed. | |
| * Returns zero on success, non-zero on parse error. Fields of *parsed | | * Returns zero on success, non-zero on parse error. Fields of *parsed | |
| * are malloc'ed, structure should be free'd with uri_free on | | * are malloc'ed, structure should be free'd with uri_free on | |
| * successful return. Any unspecified URI fields are set to NULL or 0 | | * successful return. Any unspecified URI fields are set to NULL or 0 | |
| * appropriately in *parsed. */ | | * appropriately in *parsed. */ | |
| int ne_uri_parse(const char *uri, ne_uri *parsed); | | int ne_uri_parse(const char *uri, ne_uri *parsed); | |
| | | | |
End of changes. 2 change blocks. |
| 3 lines changed or deleted | | 4 lines changed or added | |
|
| ne_utils.h | | ne_utils.h | |
| | | | |
| skipping to change at line 44 | | skipping to change at line 44 | |
| #include <trio.h> | | #include <trio.h> | |
| #endif | | #endif | |
| | | | |
| BEGIN_NEON_DECLS | | BEGIN_NEON_DECLS | |
| | | | |
| /* Returns a human-readable version string like: | | /* Returns a human-readable version string like: | |
| * "neon 0.2.0: Library build, OpenSSL support" | | * "neon 0.2.0: Library build, OpenSSL support" | |
| */ | | */ | |
| const char *ne_version_string(void); | | const char *ne_version_string(void); | |
| | | | |
|
| /* Returns non-zero if the neon API compiled in is less than | | /* Returns non-zero if library version is not of major version | |
| * major.minor. i.e. | | * 'major', or if minor version is not greater than or equal to | |
| * I am: 1.2 - neon_version_check(1, 3) => -1 | | * 'minor'. */ | |
| * I am: 0.10 - neon_version_check(0, 9) => 0 | | int ne_version_match(int major, int minor); | |
| */ | | | |
| int ne_version_minimum(int major, int minor); | | | |
| | | | |
| /* Returns non-zero if neon has support for SSL. */ | | /* Returns non-zero if neon has support for SSL. */ | |
| int ne_supports_ssl(void); | | int ne_supports_ssl(void); | |
| | | | |
| /* Use replacement snprintf's if trio is being used. */ | | /* Use replacement snprintf's if trio is being used. */ | |
| #ifdef NEON_TRIO | | #ifdef NEON_TRIO | |
| #define ne_snprintf trio_snprintf | | #define ne_snprintf trio_snprintf | |
| #define ne_vsnprintf trio_vsnprintf | | #define ne_vsnprintf trio_vsnprintf | |
| #else | | #else | |
| #define ne_snprintf snprintf | | #define ne_snprintf snprintf | |
| | | | |
| skipping to change at line 71 | | skipping to change at line 69 | |
| #endif | | #endif | |
| | | | |
| #ifndef WIN32 | | #ifndef WIN32 | |
| #undef min | | #undef min | |
| #define min(a,b) ((a)<(b)?(a):(b)) | | #define min(a,b) ((a)<(b)?(a):(b)) | |
| #endif | | #endif | |
| | | | |
| /* CONSIDER: mutt has a nicer way of way of doing debugging output... maybe | | /* CONSIDER: mutt has a nicer way of way of doing debugging output... maybe | |
| * switch to like that. */ | | * switch to like that. */ | |
| | | | |
|
| #ifdef __GNUC__ | | | |
| /* really, we want to do this if we have any C99-capable compiler, so | | | |
| * what's a better test? */ | | | |
| | | | |
| #ifndef NE_DEBUGGING | | | |
| #define NE_DEBUG(x, fmt, args...) | | | |
| #else | | | |
| #define NE_DEBUG(x, fmt, args...) do { \ | | | |
| if (((x)&ne_debug_mask) == (x)) { \ | | | |
| fflush(stdout); \ | | | |
| fprintf(ne_debug_stream, fmt, ##args); \ | | | |
| if (((x) & NE_DBG_FLUSH) == NE_DBG_FLUSH) \ | | | |
| fflush(ne_debug_stream); \ | | | |
| } \ | | | |
| } while (0) | | | |
| #endif | | | |
| | | | |
| #else /* !__GNUC__ */ | | | |
| | | | |
| #ifndef NE_DEBUGGING | | #ifndef NE_DEBUGGING | |
| #define NE_DEBUG if (0) ne_debug | | #define NE_DEBUG if (0) ne_debug | |
| #else /* DEBUGGING */ | | #else /* DEBUGGING */ | |
| #define NE_DEBUG ne_debug | | #define NE_DEBUG ne_debug | |
| #endif /* DEBUGGING */ | | #endif /* DEBUGGING */ | |
| | | | |
|
| #endif | | | |
| | | | |
| #define NE_DBG_SOCKET (1<<0) | | #define NE_DBG_SOCKET (1<<0) | |
| #define NE_DBG_HTTP (1<<1) | | #define NE_DBG_HTTP (1<<1) | |
| #define NE_DBG_XML (1<<2) | | #define NE_DBG_XML (1<<2) | |
| #define NE_DBG_HTTPAUTH (1<<3) | | #define NE_DBG_HTTPAUTH (1<<3) | |
| #define NE_DBG_HTTPPLAIN (1<<4) | | #define NE_DBG_HTTPPLAIN (1<<4) | |
| #define NE_DBG_LOCKS (1<<5) | | #define NE_DBG_LOCKS (1<<5) | |
| #define NE_DBG_XMLPARSE (1<<6) | | #define NE_DBG_XMLPARSE (1<<6) | |
| #define NE_DBG_HTTPBODY (1<<7) | | #define NE_DBG_HTTPBODY (1<<7) | |
|
| #define NE_DBG_HTTPBASIC (1<<8) | | | |
| #define NE_DBG_FLUSH (1<<30) | | #define NE_DBG_FLUSH (1<<30) | |
| | | | |
| void ne_debug_init(FILE *stream, int mask); | | void ne_debug_init(FILE *stream, int mask); | |
| extern int ne_debug_mask; | | extern int ne_debug_mask; | |
| extern FILE *ne_debug_stream; | | extern FILE *ne_debug_stream; | |
| | | | |
| void ne_debug(int ch, const char *, ...) | | void ne_debug(int ch, const char *, ...) | |
| #ifdef __GNUC__ | | #ifdef __GNUC__ | |
| __attribute__ ((format (printf, 2, 3))) | | __attribute__ ((format (printf, 2, 3))) | |
| #endif /* __GNUC__ */ | | #endif /* __GNUC__ */ | |
| ; | | ; | |
| | | | |
| /* Storing an HTTP status result */ | | /* Storing an HTTP status result */ | |
| typedef struct { | | typedef struct { | |
| int major_version; | | int major_version; | |
| int minor_version; | | int minor_version; | |
| int code; /* Status-Code value */ | | int code; /* Status-Code value */ | |
| int klass; /* Class of Status-Code (1-5) */ | | int klass; /* Class of Status-Code (1-5) */ | |
|
| const char *reason_phrase; | | char *reason_phrase; | |
| } ne_status; | | } ne_status; | |
| | | | |
| /* NB: couldn't use 'class' in ne_status because it would clash with | | /* NB: couldn't use 'class' in ne_status because it would clash with | |
| * the C++ reserved word. */ | | * the C++ reserved word. */ | |
| | | | |
| /* Parser for strings which follow the Status-Line grammar from | | /* Parser for strings which follow the Status-Line grammar from | |
|
| * RFC2616. | | * RFC2616. s->reason_phrase is malloc-allocated if non-NULL, and | |
| | | * must be free'd by the caller. | |
| * Returns: | | * Returns: | |
| * 0 on success, *s will be filled in. | | * 0 on success, *s will be filled in. | |
| * -1 on parse error. | | * -1 on parse error. | |
| */ | | */ | |
| int ne_parse_statusline(const char *status_line, ne_status *s); | | int ne_parse_statusline(const char *status_line, ne_status *s); | |
| | | | |
| END_NEON_DECLS | | END_NEON_DECLS | |
| | | | |
| #endif /* NE_UTILS_H */ | | #endif /* NE_UTILS_H */ | |
| | | | |
End of changes. 6 change blocks. |
| 30 lines changed or deleted | | 7 lines changed or added | |
|