ne_207.h | ne_207.h | |||
---|---|---|---|---|
/* | /* | |||
WebDAV 207 multi-status response handling | WebDAV 207 multi-status response handling | |||
Copyright (C) 1999-2003, Joe Orton <joe@manyfish.co.uk> | Copyright (C) 1999-2004, Joe Orton <joe@manyfish.co.uk> | |||
This library is free software; you can redistribute it and/or | This library is free software; you can redistribute it and/or | |||
modify it under the terms of the GNU Library General Public | modify it under the terms of the GNU Library General Public | |||
License as published by the Free Software Foundation; either | License as published by the Free Software Foundation; either | |||
version 2 of the License, or (at your option) any later version. | version 2 of the License, or (at your option) any later version. | |||
This library is distributed in the hope that it will be useful, | This library is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
Library General Public License for more details. | Library General Public License for more details. | |||
skipping to change at line 57 | skipping to change at line 57 | |||
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(void *userdata, void *response, | typedef void ne_207_end_response(void *userdata, void *response, | |||
const ne_status *status, | const ne_status *status, | |||
const char *description); | const char *description); | |||
/* Similarly, start and end callbacks for each propstat within the | /* Similarly, start and end callbacks for each propstat within the | |||
* response. The return value of the 'start_response' callback for | * response. The return value of the 'start_response' callback for | |||
* the response in which this propstat is contains is passed as the | * the response in which this propstat is contains is passed as the | |||
* 'response' parameter. The return value of each 'start_propstat' is | * 'response' parameter. The return value of each 'start_propstat' is | |||
* passed as the 'propstat' parameter' to the corresponding | * passed as the 'propstat' parameter' to the corresponding | |||
* 'end_propstat' callback. */ | * 'end_propstat' callback. If the start_propstat callback returns | |||
* NULL, parsing is aborted (the XML parser error must be set by the | ||||
* callback). */ | ||||
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(void *userdata, void *propstat, | typedef void ne_207_end_propstat(void *userdata, void *propstat, | |||
const ne_status *status, | const ne_status *status, | |||
const char *description); | const char *description); | |||
typedef struct ne_207_parser_s ne_207_parser; | typedef struct ne_207_parser_s ne_207_parser; | |||
/* Create 207 parser an add the handlers the the given parser's | /* Create 207 parser an add the handlers the the given parser's | |||
* handler stack. */ | * handler stack. */ | |||
ne_207_parser *ne_207_create(ne_xml_parser *parser, void *userdata); | ne_207_parser *ne_207_create(ne_xml_parser *parser, void *userdata); | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 4 lines changed or added | |||
ne_alloc.h | ne_alloc.h | |||
---|---|---|---|---|
/* | /* | |||
Replacement memory allocation handling etc. | Replacement memory allocation handling etc. | |||
Copyright (C) 1999-2002, Joe Orton <joe@manyfish.co.uk> | Copyright (C) 1999-2005, Joe Orton <joe@manyfish.co.uk> | |||
This library is free software; you can redistribute it and/or | This library is free software; you can redistribute it and/or | |||
modify it under the terms of the GNU Library General Public | modify it under the terms of the GNU Library General Public | |||
License as published by the Free Software Foundation; either | License as published by the Free Software Foundation; either | |||
version 2 of the License, or (at your option) any later version. | version 2 of the License, or (at your option) any later version. | |||
This library is distributed in the hope that it will be useful, | This library is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
Library General Public License for more details. | Library General Public License for more details. | |||
skipping to change at line 35 | skipping to change at line 35 | |||
#ifdef WIN32 | #ifdef WIN32 | |||
#include <stdlib.h> | #include <stdlib.h> | |||
#else | #else | |||
#include <sys/types.h> | #include <sys/types.h> | |||
#endif | #endif | |||
#include "ne_defs.h" | #include "ne_defs.h" | |||
BEGIN_NEON_DECLS | BEGIN_NEON_DECLS | |||
typedef void (*ne_oom_callback_fn)(void); | ||||
/* Set callback which is called if malloc() returns NULL. */ | /* Set callback which is called if malloc() returns NULL. */ | |||
void ne_oom_callback(void (*callback)(void)); | void ne_oom_callback(ne_oom_callback_fn callback); | |||
#ifndef NEON_MEMLEAK | #ifndef NEON_MEMLEAK | |||
/* Replacements for standard C library memory allocation functions, | /* Replacements for standard C library memory allocation functions, | |||
* which never return NULL. If the C library malloc() returns NULL, | * which never return NULL. If the C library malloc() returns NULL, | |||
* neon will abort(); calling an OOM callback beforehand if one is | * neon will abort(); calling an OOM callback beforehand if one is | |||
* registered. The C library will only ever return NULL if the | * registered. The C library will only ever return NULL if the | |||
* operating system does not use optimistic memory allocation. */ | * operating system does not use optimistic memory allocation. */ | |||
void *ne_malloc(size_t size); | void *ne_malloc(size_t size) ne_attribute_malloc; | |||
void *ne_calloc(size_t size); | void *ne_calloc(size_t size) ne_attribute_malloc; | |||
void *ne_realloc(void *ptr, size_t s); | void *ne_realloc(void *ptr, size_t s) ne_attribute_malloc; | |||
char *ne_strdup(const char *s); | char *ne_strdup(const char *s) ne_attribute_malloc; | |||
char *ne_strndup(const char *s, size_t n); | char *ne_strndup(const char *s, size_t n) ne_attribute_malloc; | |||
#define ne_free free | #define ne_free free | |||
#endif | #endif | |||
/* Handy macro to free things: takes an lvalue, and sets to NULL | /* Handy macro to free things: takes an lvalue, and sets to NULL | |||
* afterwards. */ | * afterwards. */ | |||
#define NE_FREE(x) do { if ((x) != NULL) ne_free((x)); (x) = NULL; } while (0) | #define NE_FREE(x) do { if ((x) != NULL) ne_free((x)); (x) = NULL; } while (0) | |||
END_NEON_DECLS | END_NEON_DECLS | |||
#endif /* NE_ALLOC_H */ | #endif /* NE_ALLOC_H */ | |||
End of changes. 4 change blocks. | ||||
7 lines changed or deleted | 9 lines changed or added | |||
ne_basic.h | ne_basic.h | |||
---|---|---|---|---|
/* | /* | |||
HTTP/1.1 methods | HTTP/1.1 methods | |||
Copyright (C) 1999-2002, Joe Orton <joe@manyfish.co.uk> | Copyright (C) 1999-2005, Joe Orton <joe@manyfish.co.uk> | |||
This library is free software; you can redistribute it and/or | This library is free software; you can redistribute it and/or | |||
modify it under the terms of the GNU Library General Public | modify it under the terms of the GNU Library General Public | |||
License as published by the Free Software Foundation; either | License as published by the Free Software Foundation; either | |||
version 2 of the License, or (at your option) any later version. | version 2 of the License, or (at your option) any later version. | |||
This library is distributed in the hope that it will be useful, | This library is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
Library General Public License for more details. | Library General Public License for more details. | |||
skipping to change at line 39 | skipping to change at line 39 | |||
BEGIN_NEON_DECLS | BEGIN_NEON_DECLS | |||
/* Perform a GET request on resource at 'path', writing the entity | /* Perform a GET request on resource at 'path', writing the entity | |||
* body which is returned to 'fd'. */ | * body which is returned to 'fd'. */ | |||
int ne_get(ne_session *sess, const char *path, int fd); | int ne_get(ne_session *sess, const char *path, int fd); | |||
/* Perform a PUT request on resource at 'path', reading the entity | /* Perform a PUT request on resource at 'path', reading the entity | |||
* body to submit from 'fd'. */ | * body to submit from 'fd'. */ | |||
int ne_put(ne_session *sess, const char *path, int fd); | int ne_put(ne_session *sess, const char *path, int fd); | |||
#ifndef NEON_NODAV | ||||
#define NE_DEPTH_ZERO (0) | #define NE_DEPTH_ZERO (0) | |||
#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. | |||
*/ | */ | |||
skipping to change at line 72 | skipping to change at line 70 | |||
const char *src, const char *dest); | const char *src, const char *dest); | |||
/* Delete resource at 'path'. */ | /* Delete resource at 'path'. */ | |||
int ne_delete(ne_session *sess, const char *path); | int ne_delete(ne_session *sess, const char *path); | |||
/* Create a collection at 'path', 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 *path); | 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 */ | ||||
/* 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 | ||||
* header; guaranteed failure if resource is modified after 'modtime'. | ||||
* 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. | ||||
*/ | ||||
int ne_put_if_unmodified(ne_session *sess, | ||||
const char *path, int fd, time_t modtime); | ||||
/* Retrieve modification time of resource at location 'path', place in | /* Retrieve modification time of resource at location 'path', place in | |||
* *modtime. (uses HEAD) */ | * *modtime. (uses HEAD) */ | |||
int ne_getmodtime(ne_session *sess, const char *path, 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. | /* Retrieve the content-type of the response; returns zero if response | |||
* Caller must free ->value after use */ | * had valid content-type, in which case all fields in *ctype are set | |||
void ne_content_type_handler(void *userdata, const char *value); | * (and never NULL); the caller must free(ctype->value) after use. | |||
* Returns non-zero on error, in which case *ctype is not altered. */ | ||||
int ne_get_content_type(ne_request *req, ne_content_type *ctype); | ||||
/* 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). Pass 'path' as "*" | /* Determines server capabilities (using OPTIONS). Pass 'path' as "*" | |||
End of changes. 4 change blocks. | ||||
17 lines changed or deleted | 6 lines changed or added | |||
ne_compress.h | ne_compress.h | |||
---|---|---|---|---|
/* | /* | |||
Compressed HTPT request/response Handling | Compressed HTTP response handling | |||
Copyright (C) 2001, Joe Orton <joe@manyfish.co.uk> | Copyright (C) 2001-2004, Joe Orton <joe@manyfish.co.uk> | |||
This library is free software; you can redistribute it and/or | This library is free software; you can redistribute it and/or | |||
modify it under the terms of the GNU Library General Public | modify it under the terms of the GNU Library General Public | |||
License as published by the Free Software Foundation; either | License as published by the Free Software Foundation; either | |||
version 2 of the License, or (at your option) any later version. | version 2 of the License, or (at your option) any later version. | |||
This library is distributed in the hope that it will be useful, | This library is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
Library General Public License for more details. | Library General Public License for more details. | |||
skipping to change at line 36 | skipping to change at line 36 | |||
typedef struct ne_decompress_s ne_decompress; | typedef struct ne_decompress_s ne_decompress; | |||
/* Call this to register a 'reader' callback which will be passed | /* Call this to register a 'reader' callback which will be passed | |||
* blocks of response body (if the 'acceptance' callback is | * blocks of response body (if the 'acceptance' callback is | |||
* successful). If the response body is returned compressed by the | * successful). If the response body is returned compressed by the | |||
* server, this reader will receive UNCOMPRESSED blocks. | * server, this reader will receive UNCOMPRESSED blocks. | |||
* | * | |||
* Returns pointer to context object which must be passed to | * Returns pointer to context object which must be passed to | |||
* ne_decompress_destroy after the request has been dispatched, to | * ne_decompress_destroy after the request has been dispatched, to | |||
* free any internal state. */ | * free any internal state. If an error occurs during decompression, | |||
* the request will be aborted and session error string set. */ | ||||
ne_decompress *ne_decompress_reader(ne_request *req, ne_accept_response acc pt, | ne_decompress *ne_decompress_reader(ne_request *req, ne_accept_response acc pt, | |||
ne_block_reader rdr, void *userdata); | ne_block_reader rdr, void *userdata); | |||
/* Free's up internal state. Returns non-zero if errors occured during | /* Destroys decompression state. */ | |||
* decompression: the session error string will have the error. */ | void ne_decompress_destroy(ne_decompress *ctx); | |||
int ne_decompress_destroy(ne_decompress *ctx); | ||||
#endif /* NE_COMPRESS_H */ | #endif /* NE_COMPRESS_H */ | |||
End of changes. 3 change blocks. | ||||
6 lines changed or deleted | 6 lines changed or added | |||
ne_defs.h | ne_defs.h | |||
---|---|---|---|---|
/* | /* | |||
Standard definitions for neon headers | Standard definitions for neon headers | |||
Copyright (C) 2003, Joe Orton <joe@manyfish.co.uk> | Copyright (C) 2003-2004, Joe Orton <joe@manyfish.co.uk> | |||
This library is free software; you can redistribute it and/or | This library is free software; you can redistribute it and/or | |||
modify it under the terms of the GNU Library General Public | modify it under the terms of the GNU Library General Public | |||
License as published by the Free Software Foundation; either | License as published by the Free Software Foundation; either | |||
version 2 of the License, or (at your option) any later version. | version 2 of the License, or (at your option) any later version. | |||
This library is distributed in the hope that it will be useful, | This library is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
Library General Public License for more details. | Library General Public License for more details. | |||
skipping to change at line 38 | skipping to change at line 38 | |||
# define BEGIN_NEON_DECLS /* empty */ | # define BEGIN_NEON_DECLS /* empty */ | |||
# define END_NEON_DECLS /* empty */ | # define END_NEON_DECLS /* empty */ | |||
#endif | #endif | |||
/* 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 | |||
#ifdef __GNUC__ | #ifdef __GNUC__ | |||
#if __GNUC__ >= 3 | ||||
#define ne_attribute_malloc __attribute__((malloc)) | ||||
#else | ||||
#define ne_attribute_malloc | ||||
#endif | ||||
#define ne_attribute(x) __attribute__(x) | #define ne_attribute(x) __attribute__(x) | |||
#else | #else | |||
#define ne_attribute(x) | #define ne_attribute(x) | |||
#define ne_attribute_malloc | ||||
#endif | #endif | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 7 lines changed or added | |||
ne_request.h | ne_request.h | |||
---|---|---|---|---|
/* | /* | |||
HTTP Request Handling | HTTP Request Handling | |||
Copyright (C) 1999-2002, Joe Orton <joe@manyfish.co.uk> | Copyright (C) 1999-2005, Joe Orton <joe@manyfish.co.uk> | |||
This library is free software; you can redistribute it and/or | This library is free software; you can redistribute it and/or | |||
modify it under the terms of the GNU Library General Public | modify it under the terms of the GNU Library General Public | |||
License as published by the Free Software Foundation; either | License as published by the Free Software Foundation; either | |||
version 2 of the License, or (at your option) any later version. | version 2 of the License, or (at your option) any later version. | |||
This library is distributed in the hope that it will be useful, | This library is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
Library General Public License for more details. | Library General Public License for more details. | |||
skipping to change at line 42 | skipping to change at line 42 | |||
#define NE_ERROR (1) /* Generic error; use ne_get_error(session) for messag e */ | #define NE_ERROR (1) /* Generic error; use ne_get_error(session) for messag e */ | |||
#define NE_LOOKUP (2) /* Server or proxy hostname lookup failed */ | #define NE_LOOKUP (2) /* Server or proxy hostname lookup failed */ | |||
#define NE_AUTH (3) /* User authentication failed on server */ | #define NE_AUTH (3) /* User authentication failed on server */ | |||
#define NE_PROXYAUTH (4) /* User authentication failed on proxy */ | #define NE_PROXYAUTH (4) /* User authentication failed on proxy */ | |||
#define NE_CONNECT (5) /* Could not connect to server */ | #define NE_CONNECT (5) /* Could not connect to server */ | |||
#define NE_TIMEOUT (6) /* Connection timed out */ | #define NE_TIMEOUT (6) /* Connection timed out */ | |||
#define NE_FAILED (7) /* The precondition failed */ | #define NE_FAILED (7) /* The precondition failed */ | |||
#define NE_RETRY (8) /* Retry request (ne_end_request ONLY) */ | #define NE_RETRY (8) /* Retry request (ne_end_request ONLY) */ | |||
#define NE_REDIRECT (9) /* See ne_redirect.h */ | #define NE_REDIRECT (9) /* See ne_redirect.h */ | |||
/* FIXME: remove this */ | ||||
#define EOL "\r\n" | ||||
/* Opaque object representing a single HTTP request. */ | /* Opaque object representing a single HTTP request. */ | |||
typedef struct ne_request_s ne_request; | typedef struct ne_request_s ne_request; | |||
/***** Request Handling *****/ | /***** Request Handling *****/ | |||
/* Create a request in session 'sess', with given method and path. | /* Create a request in session 'sess', with given method and path. | |||
* 'path' must conform to the 'abs_path' grammar in RFC2396, with an | * 'path' must conform to the 'abs_path' grammar in RFC2396, with an | |||
* optional "? query" part, and MUST be URI-escaped by the caller. */ | * optional "? query" part, and MUST be URI-escaped by the caller. */ | |||
ne_request *ne_request_create(ne_session *sess, | ne_request *ne_request_create(ne_session *sess, | |||
const char *method, const char *path); | const char *method, const char *path); | |||
/* 'buffer' will be sent as the request body with given request. */ | /* The request body will be taken from 'size' bytes of 'buffer'. */ | |||
void ne_set_request_body_buffer(ne_request *req, const char *buffer, | void ne_set_request_body_buffer(ne_request *req, const char *buffer, | |||
size_t size); | size_t size); | |||
/* Send the contents of a file as the request body; 'fd' must be a | /* The request body will be taken from 'length' bytes read from the | |||
* file descriptor of an open, seekable file. Current file offset of | * file descriptor 'fd', starting from file offset 'offset'. */ | |||
* fd is not retained (and ignored: the file is read from the the | void ne_set_request_body_fd(ne_request *req, int fd, | |||
* first byte). Returns: | off_t offset, off_t length); | |||
* 0 on okay. | ||||
* non-zero if could not determine length of file. */ | #ifdef NE_LFS | |||
int ne_set_request_body_fd(ne_request *req, int fd); | /* Alternate version of ne_set_request_body_fd taking off64_t | |||
* offset type for systems supporting _LARGEFILE64_SOURCE. */ | ||||
void ne_set_request_body_fd64(ne_request *req, int fd, | ||||
off64_t offset, off64_t length); | ||||
#endif | ||||
/* "Pull"-based request body provider: a callback which is invoked to | /* "Pull"-based request body provider: a callback which is invoked to | |||
* provide blocks of request body on demand. | * provide blocks of request body on demand. | |||
* | * | |||
* Before each time the body is provided, the callback will be called | * Before each time the body is provided, the callback will be called | |||
* once with buflen == 0. The body may have to be provided >1 time | * once with buflen == 0. The body may have to be provided >1 time | |||
* per request (for authentication retries etc.). | * per request (for authentication retries etc.). | |||
* | * | |||
* The callback must return: | * For a call with buflen == 0, the callback must return zero on success | |||
* <0 : error, abort request. | * or non-zero on error; the session error string must be set on error. | |||
* For a call with buflen > 0, the callback must return: | ||||
* <0 : error, abort request; session error string must be | ||||
set. | ||||
* 0 : ignore 'buffer' contents, end of body. | * 0 : ignore 'buffer' contents, end of body. | |||
* 0 < x <= buflen : buffer contains x bytes of body data. */ | * 0 < x <= buflen : buffer contains x bytes of body data. */ | |||
typedef ssize_t (*ne_provide_body)(void *userdata, | typedef ssize_t (*ne_provide_body)(void *userdata, | |||
char *buffer, size_t buflen); | char *buffer, size_t buflen); | |||
/* Install a callback which is invoked as needed to provide request | /* Install a callback which is invoked as needed to provide the | |||
* body blocks. Total request body is 'size' bytes: the callback MUST | * request body, a block at a time. The total size of the request | |||
* ensure it returns in total exactly 'size' bytes each time the | * body is 'length'; the callback must ensure that it returns no more | |||
* request body is provided. */ | * than 'length' bytes in total. */ | |||
void ne_set_request_body_provider(ne_request *req, size_t size, | void ne_set_request_body_provider(ne_request *req, off_t length, | |||
ne_provide_body provider, void *userdata); | ne_provide_body provider, void *userdata); | |||
/* Handling response bodies... you provide TWO callbacks: | #ifdef NE_LFS | |||
/* Duplicate version of ne_set_request_body_provider, taking an off64_t | ||||
* offset. */ | ||||
void ne_set_request_body_provider64(ne_request *req, off64_t length, | ||||
ne_provide_body provider, void *userdat | ||||
a); | ||||
#endif | ||||
/* Handling response bodies; two callbacks must be provided: | ||||
* | * | |||
* 1) 'acceptance' callback: determines whether you want to handle the | * 1) 'acceptance' callback: determines whether you want to handle the | |||
* response body given the response-status information, e.g., if you | * response body given the response-status information, e.g., if you | |||
* only want 2xx responses, say so here. | * only want 2xx responses, say so here. | |||
* | * | |||
* 2) 'reader' callback: passed blocks of the response-body as they | * 2) 'reader' callback: passed blocks of the response-body as they | |||
* arrive, if the acceptance callback returned non-zero. */ | * arrive, if the acceptance callback returned non-zero. */ | |||
/* 'acceptance' callback type. Return non-zero to accept the response, | /* 'acceptance' callback type. Return non-zero to accept the response, | |||
* else zero to ignore it. */ | * else zero to ignore it. */ | |||
typedef int (*ne_accept_response)( | typedef int (*ne_accept_response)(void *userdata, ne_request *req, | |||
void *userdata, ne_request *req, const ne_status *st); | const ne_status *st); | |||
/* An 'acceptance' callback which only accepts 2xx-class responses. | /* An 'acceptance' callback which only accepts 2xx-class responses. | |||
* Ignores userdata. */ | * Ignores userdata. */ | |||
int ne_accept_2xx(void *userdata, ne_request *req, const ne_status *st); | int ne_accept_2xx(void *userdata, ne_request *req, const ne_status *st); | |||
/* An acceptance callback which accepts all responses. Ignores | /* An acceptance callback which accepts all responses. Ignores | |||
* userdata. */ | * userdata. */ | |||
int ne_accept_always(void *userdata, ne_request *req, const ne_status *st); | int ne_accept_always(void *userdata, ne_request *req, const ne_status *st); | |||
/* Callback for reading a block of data. */ | /* Callback for reading a block of data. Returns zero on success, or | |||
typedef void (*ne_block_reader)(void *userdata, const char *buf, size_t len | * non-zero on error. If returning an error, the response will be | |||
); | * aborted and the callback will not be invoked again. The request | |||
* dispatch (or ne_read_response_block call) will fail with NE_ERROR; | ||||
* the session error string should have been set by the callback. */ | ||||
typedef int (*ne_block_reader)(void *userdata, const char *buf, size_t len) | ||||
; | ||||
/* Add a response reader for the given request, with the given | /* Add a response reader for the given request, with the given | |||
* acceptance function. userdata is passed as the first argument to | * acceptance function. userdata is passed as the first argument to | |||
* the acceptance + reader callbacks. | * the acceptance + reader callbacks. | |||
* | * | |||
* The acceptance callback is called once each time the request is | * The acceptance callback is called once each time the request is | |||
* sent: it may be sent >1 time because of authentication retries etc. | * sent: it may be sent >1 time because of authentication retries etc. | |||
* For each time the acceptance callback is called, if it returns | * For each time the acceptance callback is called, if it returns | |||
* non-zero, blocks of the response body will be passed to the reader | * non-zero, blocks of the response body will be passed to the reader | |||
* callback as the response is read. After all the response body has | * callback as the response is read. After all the response body has | |||
* been read, the callback will be called with a 'len' argument of | * been read, the callback will be called with a 'len' argument of | |||
* zero. */ | * zero. */ | |||
void ne_add_response_body_reader(ne_request *req, ne_accept_response accpt, | void ne_add_response_body_reader(ne_request *req, ne_accept_response accpt, | |||
ne_block_reader reader, void *userdata); | ne_block_reader reader, void *userdata); | |||
/* Handle response headers. Each handler is associated with a specific | /* Retrieve the value of the response header field with given name; | |||
* header field (indicated by name). The handler is then passed the | * returns NULL if no response header with given name was found. The | |||
* value of this header field. */ | * return value is valid only until the next call to either | |||
* ne_request_create or ne_begin_request for this request. */ | ||||
/* The header handler callback type */ | const char *ne_get_response_header(ne_request *req, const char *name); | |||
typedef void (*ne_header_handler)(void *userdata, const char *value); | ||||
/* Adds a response header handler for the given request. userdata is passed | ||||
* as the first argument to the header handler, and the 'value' is the | ||||
* header field value (i.e. doesn't include the "Header-Name: " part"). | ||||
*/ | ||||
void ne_add_response_header_handler(ne_request *req, const char *name, | ||||
ne_header_handler hdl, void *userdata); | ||||
/* Add handler which is passed ALL header values regardless of name */ | ||||
void ne_add_response_header_catcher(ne_request *req, | ||||
ne_header_handler hdl, void *userdata); | ||||
/* Stock header handlers: | /* Iterator interface for response headers: if passed a NULL cursor, | |||
* 'duplicate': *(char **)userdata = strdup(value) | * returns the first header; if passed a non-NULL cursor pointer, | |||
* 'numeric': *(int *)userdata = atoi(value) | * returns the next header. The return value is a cursor pointer: if | |||
* e.g. | * it is non-NULL, *name and *value are set to the name and value of | |||
* int mynum; | * the header field. If the return value is NULL, no more headers are | |||
* ne_add_response_header_handler(myreq, "Content-Length", | * found, *name and *value are undefined. | |||
* ne_handle_numeric_handler, &mynum); | * | |||
* ... arranges mynum to be set to the value of the Content-Length header. | * The order in which response headers is returned is undefined. Both | |||
*/ | * the cursor and name/value pointers are valid only until the next | |||
void ne_duplicate_header(void *userdata, const char *value); | * call to either ne_request_destroy or ne_begin_request for this | |||
void ne_handle_numeric_header(void *userdata, const char *value); | * request. */ | |||
void *ne_response_header_iterate(ne_request *req, void *cursor, | ||||
const char **name, const char **value); | ||||
/* Adds a header to the request with given name and value. */ | /* Adds a header to the request with given name and value. */ | |||
void ne_add_request_header(ne_request *req, const char *name, | void ne_add_request_header(ne_request *req, const char *name, | |||
const char *value); | const char *value); | |||
/* Adds a header to the request with given name, using printf-like | /* Adds a header to the request with given name, using printf-like | |||
* format arguments for the value. */ | * format arguments for the value. */ | |||
void ne_print_request_header(ne_request *req, const char *name, | void ne_print_request_header(ne_request *req, const char *name, | |||
const char *format, ...) | const char *format, ...) | |||
ne_attribute((format(printf, 3, 4))); | ne_attribute((format(printf, 3, 4))); | |||
/* ne_request_dispatch: Sends the given request, and reads the | /* ne_request_dispatch: Sends the given request, and reads the | |||
* response. Response-Status information can be retrieve with | * response. Returns: | |||
* ne_get_status(req). | * - NE_OK if the request was sent and response read successfully | |||
* | * - NE_AUTH, NE_PROXYAUTH for a server or proxy server authentication err | |||
* NE_OK if request sent + response read okay. | or | |||
* NE_AUTH user not authorised on server | * - NE_CONNECT if connection could not be established | |||
* NE_PROXYAUTH user not authorised on proxy server | * - NE_TIMEOUT if an timeout occurred sending or reading from the server | |||
* NE_CONNECT could not connect to server/proxy server | * - NE_ERROR for other fatal dispatch errors | |||
* NE_TIMEOUT connection timed out mid-request | * On any error, the session error string is set. On success or | |||
* NE_ERROR for other errors, and ne_get_error() should | * authentication error, the actual response-status can be retrieved using | |||
* return a meaningful error string | * ne_get_status(). */ | |||
*/ | ||||
int ne_request_dispatch(ne_request *req); | int ne_request_dispatch(ne_request *req); | |||
/* Returns a pointer to the response status information for the given | /* Returns a pointer to the response status information for the given | |||
* request; pointer is valid until request object is destroyed. */ | * request; pointer is valid until request object is destroyed. */ | |||
const ne_status *ne_get_status(const ne_request *req) ne_attribute((const)) ; | const ne_status *ne_get_status(const ne_request *req) ne_attribute((const)) ; | |||
/* Returns pointer to session associated with request. */ | /* Returns pointer to session associated with request. */ | |||
ne_session *ne_get_session(const ne_request *req); | ne_session *ne_get_session(const ne_request *req) ne_attribute((const)); | |||
/* 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) | * (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 into the passed buffer of size 'buflen'. | |||
* 'buflen' must be length of buffer. | ||||
* | * | |||
* Returns: | * Returns: | |||
* <0 - error, stop reading. | * <0 - error, stop reading. | |||
* 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 ); | |||
/* Read response blocks until end of response; exactly equivalent to | ||||
* calling ne_read_response_block() until it returns 0. Returns | ||||
* non-zero on error. */ | ||||
int ne_discard_response(ne_request *req); | ||||
/* Read response blocks until end of response, writing content to the | ||||
* given file descriptor. Returns NE_ERROR on error. */ | ||||
int ne_read_response_to_fd(ne_request *req, int fd); | ||||
/* If 'flag' is non-zer, enable the HTTP/1.1 "Expect: 100-continue" | ||||
* feature for the request, which allows the server to send an error | ||||
* response before the request body is sent. This should only be used | ||||
* if the server is known to support the feature (not all HTTP/1.1 | ||||
* servers do); the request will time out and fail otherwise. */ | ||||
void ne_set_request_expect100(ne_request *req, int flag); | ||||
/**** 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; passed the request method, | /* Hook called when a create is created; passed the request method, | |||
* and the string used as the Request-URI (which may be an abs_path, | * and the string used as the Request-URI (which may be an abs_path, | |||
* or an absoluteURI, depending on whether an HTTP proxy is in | * or an absoluteURI, depending on whether an HTTP proxy is in | |||
* use). */ | * use). */ | |||
typedef void (*ne_create_request_fn)(ne_request *req, void *userdata, | typedef void (*ne_create_request_fn)(ne_request *req, void *userdata, | |||
const char *method, const char *requri) ; | const char *method, const char *requri) ; | |||
End of changes. 15 change blocks. | ||||
67 lines changed or deleted | 87 lines changed or added | |||
ne_session.h | ne_session.h | |||
---|---|---|---|---|
/* | /* | |||
HTTP session handling | HTTP session handling | |||
Copyright (C) 1999-2003, Joe Orton <joe@manyfish.co.uk> | Copyright (C) 1999-2005, Joe Orton <joe@manyfish.co.uk> | |||
This library is free software; you can redistribute it and/or | This library is free software; you can redistribute it and/or | |||
modify it under the terms of the GNU Library General Public | modify it under the terms of the GNU Library General Public | |||
License as published by the Free Software Foundation; either | License as published by the Free Software Foundation; either | |||
version 2 of the License, or (at your option) any later version. | version 2 of the License, or (at your option) any later version. | |||
This library is distributed in the hope that it will be useful, | This library is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
Library General Public License for more details. | Library General Public License for more details. | |||
skipping to change at line 30 | skipping to change at line 30 | |||
*/ | */ | |||
#ifndef NE_SESSION_H | #ifndef NE_SESSION_H | |||
#define NE_SESSION_H 1 | #define NE_SESSION_H 1 | |||
#include <sys/types.h> | #include <sys/types.h> | |||
#include "ne_ssl.h" | #include "ne_ssl.h" | |||
#include "ne_uri.h" /* for ne_uri */ | #include "ne_uri.h" /* for ne_uri */ | |||
#include "ne_defs.h" | #include "ne_defs.h" | |||
#include "ne_socket.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, unsigned int port); | const char *hostname, unsigned int port); | |||
skipping to change at line 52 | skipping to change at line 53 | |||
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, | void ne_session_proxy(ne_session *sess, | |||
const char *hostname, unsigned int port); | const char *hostname, unsigned int port); | |||
/* Set protocol options for session: | /* Disable use of persistent connection if 'flag' is non-zero, else | |||
* expect100: Defaults to OFF | * enable (the default). */ | |||
* persist: Defaults to ON | void ne_set_persist(ne_session *sess, int flag); | |||
* | ||||
* expect100: When set, send the "Expect: 100-continue" request header | /* Bypass the normal name resolution; force the use of specific set of | |||
* with requests with bodies. | * addresses for this session, addrs[0]...addrs[n-1]. The addrs array | |||
* | * must remain valid until the session is destroyed. */ | |||
* persist: When set, use a persistent connection. (Generally, | void ne_set_addrlist(ne_session *sess, const ne_inet_addr **addrs, size_t n | |||
* you don't want to turn this off.) | ); | |||
* */ | ||||
void ne_set_expect100(ne_session *sess, int use_expect100); | ||||
void ne_set_persist(ne_session *sess, int persist); | ||||
/* Progress callback. */ | /* Progress callback. */ | |||
typedef void (*ne_progress)(void *userdata, off_t progress, off_t total); | typedef void (*ne_progress)(void *userdata, off_t progress, off_t total); | |||
/* 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 | /* Store an opaque context for the session, 'priv' is returned by a | |||
* call to ne_session_get_private with the same ID. */ | * call to ne_session_get_private with the same ID. */ | |||
End of changes. 3 change blocks. | ||||
13 lines changed or deleted | 11 lines changed or added | |||
ne_socket.h | ne_socket.h | |||
---|---|---|---|---|
/* | /* | |||
socket handling interface | socket handling interface | |||
Copyright (C) 1999-2003, Joe Orton <joe@manyfish.co.uk> | Copyright (C) 1999-2005, Joe Orton <joe@manyfish.co.uk> | |||
This library is free software; you can redistribute it and/or | This library is free software; you can redistribute it and/or | |||
modify it under the terms of the GNU Library General Public | modify it under the terms of the GNU Library General Public | |||
License as published by the Free Software Foundation; either | License as published by the Free Software Foundation; either | |||
version 2 of the License, or (at your option) any later version. | version 2 of the License, or (at your option) any later version. | |||
This library is distributed in the hope that it will be useful, | This library is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
Library General Public License for more details. | Library General Public License for more details. | |||
skipping to change at line 39 | skipping to change at line 39 | |||
BEGIN_NEON_DECLS | BEGIN_NEON_DECLS | |||
#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) */ | /* Connection was reset (e.g. server crashed) */ | |||
#define NE_SOCK_RESET (-4) | #define NE_SOCK_RESET (-4) | |||
/* Secure connection was subject to possible truncation attack. */ | /* Secure connection was closed without proper SSL shutdown. */ | |||
#define NE_SOCK_TRUNC (-5) | #define NE_SOCK_TRUNC (-5) | |||
/* ne_socket represents a TCP socket. */ | /* ne_socket represents a TCP socket. */ | |||
typedef struct ne_socket_s ne_socket; | typedef struct ne_socket_s ne_socket; | |||
/* ne_sock_addr represents an address object. */ | /* ne_sock_addr represents an address object. */ | |||
typedef struct ne_sock_addr_s ne_sock_addr; | typedef struct ne_sock_addr_s ne_sock_addr; | |||
#ifndef NE_INET_ADDR_DEFINED | #ifndef NE_INET_ADDR_DEFINED | |||
typedef struct ne_inet_addr_s ne_inet_addr; | typedef struct ne_inet_addr_s ne_inet_addr; | |||
#endif | #endif | |||
/* 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); | |||
/* Resolve the given hostname. 'flags' are currently ignored. Hex | /* Resolve the given hostname. 'flags' must be zero. Hex | |||
* string IPv6 addresses (e.g. `::1') may be enclosed in brackets | * string IPv6 addresses (e.g. `::1') may be enclosed in brackets | |||
* (e.g. `[::1]'). */ | * (e.g. `[::1]'). */ | |||
ne_sock_addr *ne_addr_resolve(const char *hostname, int flags); | ne_sock_addr *ne_addr_resolve(const char *hostname, int flags); | |||
/* Returns zero if name resolution was successful, non-zero on | /* Returns zero if name resolution was successful, non-zero on | |||
* error. */ | * error. */ | |||
int ne_addr_result(const ne_sock_addr *addr); | int ne_addr_result(const ne_sock_addr *addr); | |||
/* Returns the first network address associated with the 'addr' | /* Returns the first network address associated with the 'addr' | |||
* object. Undefined behaviour if ne_addr_result returns non-zero for | * object. Undefined behaviour if ne_addr_result returns non-zero for | |||
skipping to change at line 105 | skipping to change at line 105 | |||
/* Create a network address from raw byte representation (in network | /* Create a network address from raw byte representation (in network | |||
* byte order) of given type. 'raw' must be four bytes for an IPv4 | * byte order) of given type. 'raw' must be four bytes for an IPv4 | |||
* address, 16 bytes for an IPv6 address. May return NULL if address | * address, 16 bytes for an IPv6 address. May return NULL if address | |||
* type is not supported. */ | * type is not supported. */ | |||
ne_inet_addr *ne_iaddr_make(ne_iaddr_type type, const unsigned char *raw); | ne_inet_addr *ne_iaddr_make(ne_iaddr_type type, const unsigned char *raw); | |||
/* Compare two network addresses i1 and i2; return non-zero if they | /* Compare two network addresses i1 and i2; return non-zero if they | |||
* are not equal. */ | * are not equal. */ | |||
int ne_iaddr_cmp(const ne_inet_addr *i1, const ne_inet_addr *i2); | int ne_iaddr_cmp(const ne_inet_addr *i1, const ne_inet_addr *i2); | |||
/* Returns the type of the given network address. */ | ||||
ne_iaddr_type ne_iaddr_typeof(const ne_inet_addr *ia); | ||||
/* Prints the string representation of network address 'ia' into the | /* Prints the string representation of network address 'ia' into the | |||
* 'buffer', which is of size 'bufsiz'. Returns 'buffer'. */ | * 'buffer', which is of size 'bufsiz'. Returns 'buffer'. */ | |||
char *ne_iaddr_print(const ne_inet_addr *ia, char *buffer, size_t bufsiz); | char *ne_iaddr_print(const ne_inet_addr *ia, char *buffer, size_t bufsiz); | |||
/* Free a network address created using ne_iaddr_make. */ | /* Free a network address created using ne_iaddr_make. */ | |||
void ne_iaddr_free(ne_inet_addr *addr); | void ne_iaddr_free(ne_inet_addr *addr); | |||
/* Create a TCP socket; returns NULL on error. */ | /* Create a TCP socket; returns NULL on error. */ | |||
ne_socket *ne_sock_create(void); | ne_socket *ne_sock_create(void); | |||
skipping to change at line 156 | skipping to change at line 159 | |||
int ne_sock_fullwrite(ne_socket *sock, const char *data, size_t count); | int ne_sock_fullwrite(ne_socket *sock, const char *data, size_t count); | |||
/* Reads an LF-terminated line into 'buffer', and NUL-terminate it. | /* Reads an LF-terminated line into 'buffer', and NUL-terminate it. | |||
* At most 'len' bytes are read (including the NUL terminator). | * At most 'len' bytes are read (including the NUL terminator). | |||
* Returns: | * Returns: | |||
* NE_SOCK_* on error, | * NE_SOCK_* on error, | |||
* >0 number of bytes read (including NUL terminator) | * >0 number of bytes read (including NUL terminator) | |||
*/ | */ | |||
ssize_t ne_sock_readline(ne_socket *sock, char *buffer, size_t len); | 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, | |||
* on error. */ | * NE_SOCK_* on error. */ | |||
ssize_t ne_sock_fullread(ne_socket *sock, char *buffer, size_t len); | ssize_t ne_sock_fullread(ne_socket *sock, char *buffer, size_t len); | |||
/* Accept a connection on listening socket 'fd'. */ | /* Accept a connection on listening socket 'fd'. */ | |||
int ne_sock_accept(ne_socket *sock, int fd); | int ne_sock_accept(ne_socket *sock, int fd); | |||
/* Returns the file descriptor used for socket 'sock'. */ | /* Returns the file descriptor used for socket 'sock'. */ | |||
int ne_sock_fd(const ne_socket *sock); | int ne_sock_fd(const ne_socket *sock); | |||
/* Close the socket, and destroy the 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. */ | /* 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); | |||
/* Returns the standard TCP port for the given service, or zero if | /* Negotiate an SSL connection on socket as an SSL server, using given | |||
* none is known. */ | * SSL context. */ | |||
int ne_service_lookup(const char *name); | int ne_sock_accept_ssl(ne_socket *sock, ne_ssl_context *ctx); | |||
/* Enable SSL with an already-negotiated SSL socket. */ | ||||
void ne_sock_switch_ssl(ne_socket *sock, void *ssl); | ||||
/* Perform an SSL negotiation on 'sock', using given context. */ | ||||
int ne_sock_connect_ssl(ne_socket *sock, ne_ssl_context *ctx); | ||||
/* Return SSL socket object in use for 'sock'. */ | /* Negotiate an SSL connection on socket as an SSL client, using given | |||
typedef struct ne_ssl_socket_s ne_ssl_socket; | * SSL context. The 'userdata' parameter is associated with the | |||
ne_ssl_socket *ne_sock_sslsock(ne_socket *sock); | * underlying SSL library's socket structure for use in callbacks. | |||
* Returns zero on success, or non-zero on error. */ | ||||
int ne_sock_connect_ssl(ne_socket *sock, ne_ssl_context *ctx, | ||||
void *userdata); | ||||
END_NEON_DECLS | END_NEON_DECLS | |||
#endif /* NE_SOCKET_H */ | #endif /* NE_SOCKET_H */ | |||
End of changes. 7 change blocks. | ||||
17 lines changed or deleted | 17 lines changed or added | |||
ne_ssl.h | ne_ssl.h | |||
---|---|---|---|---|
/* | /* | |||
SSL/TLS abstraction layer for neon | SSL/TLS abstraction layer for neon | |||
Copyright (C) 2003-2004, Joe Orton <joe@manyfish.co.uk> | Copyright (C) 2003-2005, Joe Orton <joe@manyfish.co.uk> | |||
This library is free software; you can redistribute it and/or | This library is free software; you can redistribute it and/or | |||
modify it under the terms of the GNU Library General Public | modify it under the terms of the GNU Library General Public | |||
License as published by the Free Software Foundation; either | License as published by the Free Software Foundation; either | |||
version 2 of the License, or (at your option) any later version. | version 2 of the License, or (at your option) any later version. | |||
This library is distributed in the hope that it will be useful, | This library is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
Library General Public License for more details. | Library General Public License for more details. | |||
skipping to change at line 68 | skipping to change at line 68 | |||
* caller. */ | * caller. */ | |||
char *ne_ssl_cert_export(const ne_ssl_certificate *cert); | char *ne_ssl_cert_export(const ne_ssl_certificate *cert); | |||
/* Import a certificate from a base64-encoded string as returned by | /* Import a certificate from a base64-encoded string as returned by | |||
* ne_ssl_cert_export(). Returns a certificate object or NULL if | * ne_ssl_cert_export(). Returns a certificate object or NULL if | |||
* 'data' was not valid. */ | * 'data' was not valid. */ | |||
ne_ssl_certificate *ne_ssl_cert_import(const char *data); | ne_ssl_certificate *ne_ssl_cert_import(const char *data); | |||
/* Returns the identity of the certificate, or NULL if none is given. | /* Returns the identity of the certificate, or NULL if none is given. | |||
* For a server certificate this will be the hostname of the server to | * For a server certificate this will be the hostname of the server to | |||
* whom the cert was issued. */ | * whom the cert was issued. String returned is UTF-8-encoded. */ | |||
const char *ne_ssl_cert_identity(const ne_ssl_certificate *cert); | const char *ne_ssl_cert_identity(const ne_ssl_certificate *cert); | |||
/* Return the certificate of the entity which signed certificate | /* Return the certificate of the entity which signed certificate | |||
* 'cert'. Returns NULL if 'cert' is self-signed or the issuer | * 'cert'. Returns NULL if 'cert' is self-signed or the issuer | |||
* certificate is not available. */ | * certificate is not available. */ | |||
const ne_ssl_certificate *ne_ssl_cert_signedby(const ne_ssl_certificate *ce rt); | const ne_ssl_certificate *ne_ssl_cert_signedby(const ne_ssl_certificate *ce rt); | |||
/* Returns the distinguished name of the certificate issuer. */ | /* Returns the distinguished name of the certificate issuer. */ | |||
const ne_ssl_dname *ne_ssl_cert_issuer(const ne_ssl_certificate *cert); | const ne_ssl_dname *ne_ssl_cert_issuer(const ne_ssl_certificate *cert); | |||
skipping to change at line 117 | skipping to change at line 117 | |||
/* A client certificate (and private key). */ | /* A client certificate (and private key). */ | |||
typedef struct ne_ssl_client_cert_s ne_ssl_client_cert; | typedef struct ne_ssl_client_cert_s ne_ssl_client_cert; | |||
/* Read a client certificate and private key from a PKCS12 file; | /* Read a client certificate and private key from a PKCS12 file; | |||
* returns NULL if the file could not be parsed. If the client cert | * returns NULL if the file could not be parsed. If the client cert | |||
* is encrypted, it must be decrypted before use. */ | * is encrypted, it must be decrypted before use. */ | |||
ne_ssl_client_cert *ne_ssl_clicert_read(const char *filename); | ne_ssl_client_cert *ne_ssl_clicert_read(const char *filename); | |||
/* Returns the "friendly name" given for the client cert, or NULL if | /* Returns the "friendly name" given for the client cert, or NULL if | |||
* none given. This can be called before or after the client cert has | * none given. This can be called before or after the client cert has | |||
* been decrypted. Returns a NUL-terminated string. */ | * been decrypted. Returns a NUL-terminated, UTF-8-encoded string. */ | |||
const char *ne_ssl_clicert_name(ne_ssl_client_cert *ccert); | const char *ne_ssl_clicert_name(const ne_ssl_client_cert *ccert); | |||
/* Returns non-zero if client cert is encrypted. */ | /* Returns non-zero if client cert is encrypted. */ | |||
int ne_ssl_clicert_encrypted(const ne_ssl_client_cert *ccert); | int ne_ssl_clicert_encrypted(const ne_ssl_client_cert *ccert); | |||
/* Decrypt the encrypted client cert using given password. Returns | /* Decrypt the encrypted client cert using given password. Returns | |||
* non-zero on failure, in which case, the function can be called | * non-zero on failure, in which case, the function can be called | |||
* again with a different password. For a ccert on which _encrypted() | * again with a different password. For a ccert on which _encrypted() | |||
* returns 0, calling _decrypt results in undefined behaviour. */ | * returns 0, calling _decrypt results in undefined behaviour. */ | |||
int ne_ssl_clicert_decrypt(ne_ssl_client_cert *ccert, const char *password) ; | int ne_ssl_clicert_decrypt(ne_ssl_client_cert *ccert, const char *password) ; | |||
/* Return the actual certificate part of the client certificate (never | /* Return the actual certificate part of the client certificate (never | |||
* returns NULL). */ | * returns NULL). */ | |||
const ne_ssl_certificate *ne_ssl_clicert_owner(const ne_ssl_client_cert *cc ert); | const ne_ssl_certificate *ne_ssl_clicert_owner(const ne_ssl_client_cert *cc ert); | |||
/* Deallocate memory associated with a client certificate. */ | /* Deallocate memory associated with a client certificate. */ | |||
void ne_ssl_clicert_free(ne_ssl_client_cert *ccert); | void ne_ssl_clicert_free(ne_ssl_client_cert *ccert); | |||
/* An SSL context; only necessary when interfacing with ne_socket.h. */ | /* SSL context object. The interfaces to manipulate an SSL context | |||
* are only needed when interfacing directly with ne_socket.h. */ | ||||
typedef struct ne_ssl_context_s ne_ssl_context; | typedef struct ne_ssl_context_s ne_ssl_context; | |||
/* Context creation modes: */ | ||||
#define NE_SSL_CTX_CLIENT (0) /* client context */ | ||||
#define NE_SSL_CTX_SERVER (1) /* default server context */ | ||||
#define NE_SSL_CTX_SERVERv2 (2) /* SSLv2-specific server context */ | ||||
/* Create an SSL context. */ | /* Create an SSL context. */ | |||
ne_ssl_context *ne_ssl_context_create(void); | ne_ssl_context *ne_ssl_context_create(int mode); | |||
/* Trust the given certificate 'cert' in context 'ctx'. */ | /* Client mode: trust the given certificate 'cert' in context 'ctx'. */ | |||
void ne_ssl_ctx_trustcert(ne_ssl_context *ctx, const ne_ssl_certificate *ce | void ne_ssl_context_trustcert(ne_ssl_context *ctx, const ne_ssl_certificate | |||
rt); | *cert); | |||
/* Server mode: use given cert and key (filenames to PEM certificates). */ | ||||
int ne_ssl_context_keypair(ne_ssl_context *ctx, | ||||
const char *cert, const char *key); | ||||
/* Server mode: set client cert verification options: required is non-zero | ||||
if | ||||
* a client cert is required, if ca_names is non-NULL it is a filename cont | ||||
aining | ||||
* a set of PEM certs from which CA names are sent in the ccert request. */ | ||||
int ne_ssl_context_set_verify(ne_ssl_context *ctx, int required, | ||||
const char *ca_names, const char *verify_cas) | ||||
; | ||||
/* Destroy an SSL context. */ | /* Destroy an SSL context. */ | |||
void ne_ssl_context_destroy(ne_ssl_context *ctx); | void ne_ssl_context_destroy(ne_ssl_context *ctx); | |||
END_NEON_DECLS | END_NEON_DECLS | |||
#endif | #endif | |||
End of changes. 7 change blocks. | ||||
9 lines changed or deleted | 28 lines changed or added | |||
ne_string.h | ne_string.h | |||
---|---|---|---|---|
/* | /* | |||
String utility functions | String utility functions | |||
Copyright (C) 1999-2002, Joe Orton <joe@manyfish.co.uk> | Copyright (C) 1999-2005, Joe Orton <joe@manyfish.co.uk> | |||
This library is free software; you can redistribute it and/or | This library is free software; you can redistribute it and/or | |||
modify it under the terms of the GNU Library General Public | modify it under the terms of the GNU Library General Public | |||
License as published by the Free Software Foundation; either | License as published by the Free Software Foundation; either | |||
version 2 of the License, or (at your option) any later version. | version 2 of the License, or (at your option) any later version. | |||
This library is distributed in the hope that it will be useful, | This library is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
Library General Public License for more details. | Library General Public License for more details. | |||
skipping to change at line 60 | skipping to change at line 60 | |||
/* A base64 encoder: converts 'len' bytes of 'text' to base64. | /* A base64 encoder: converts 'len' bytes of 'text' to base64. | |||
* Returns malloc-allocated buffer; caller must free(). */ | * Returns malloc-allocated buffer; caller must free(). */ | |||
char *ne_base64(const unsigned char *text, size_t len); | char *ne_base64(const unsigned char *text, size_t len); | |||
/* Base64 decoder; decodes NUL-terminated base64-encoded string | /* Base64 decoder; decodes NUL-terminated base64-encoded string | |||
* 'data', places malloc-allocated raw data in '*out', returns length, | * 'data', places malloc-allocated raw data in '*out', returns length, | |||
* or zero on decode error (in which case *out is undefined). */ | * or zero on decode error (in which case *out is undefined). */ | |||
size_t ne_unbase64(const char *data, unsigned char **out); | size_t ne_unbase64(const char *data, unsigned char **out); | |||
/*** OBSOLETE INTERFACES ***/ | ||||
char **split_string(const char *str, const char seperator, | ||||
const char *quotes, const char *whitespace); | ||||
char **split_string_c(const char *str, const char seperator, | ||||
const char *quotes, const char *whitespace, int *count | ||||
); | ||||
char **pair_string(const char *str, const char compsep, const char kvsep, | ||||
const char *quotes, const char *whitespace); | ||||
void split_string_free(char **components); | ||||
void pair_string_free(char **pairs); | ||||
/*** END OF OBSOLETE INTERFACES */ | ||||
/* String buffer handling. (Strings are zero-terminated still). A | /* String buffer handling. (Strings are zero-terminated still). A | |||
* string buffer ne_buffer * which grows dynamically with the | * string buffer ne_buffer * which grows dynamically with the | |||
* string. */ | * string. */ | |||
typedef struct { | typedef struct { | |||
char *data; /* contents: null-terminated string. */ | char *data; /* contents: null-terminated string. */ | |||
size_t used; /* used bytes in buffer */ | size_t used; /* used bytes in buffer */ | |||
size_t length; /* length of buffer */ | size_t length; /* length of buffer */ | |||
} ne_buffer; | } ne_buffer; | |||
skipping to change at line 106 | skipping to change at line 95 | |||
void ne_buffer_destroy(ne_buffer *buf); | void ne_buffer_destroy(ne_buffer *buf); | |||
/* Append a NUL-terminated string 'str' to buf. */ | /* Append a NUL-terminated string 'str' to buf. */ | |||
void ne_buffer_zappend(ne_buffer *buf, const char *str); | void ne_buffer_zappend(ne_buffer *buf, const char *str); | |||
/* Append 'len' bytes of 'data' to buf. 'data' does not need to be | /* Append 'len' bytes of 'data' to buf. 'data' does not need to be | |||
* NUL-terminated. The resultant string will have a NUL-terminator, | * NUL-terminated. The resultant string will have a NUL-terminator, | |||
* either way. */ | * either way. */ | |||
void ne_buffer_append(ne_buffer *buf, const char *data, size_t len); | void ne_buffer_append(ne_buffer *buf, const char *data, size_t len); | |||
/* Append a literal constant string 'str' to buffer 'buf'. */ | ||||
#define ne_buffer_czappend(buf, str) \ | ||||
ne_buffer_append((buf), (str), sizeof((str)) - 1) | ||||
/* Empties the contents of buf; makes the buffer zero-length. */ | /* Empties the contents of buf; makes the buffer zero-length. */ | |||
void ne_buffer_clear(ne_buffer *buf); | void ne_buffer_clear(ne_buffer *buf); | |||
/* 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. */ | |||
skipping to change at line 135 | skipping to change at line 128 | |||
#define ne_strnzcpy(dest, src, n) do { \ | #define ne_strnzcpy(dest, src, n) do { \ | |||
strncpy(dest, src, n-1); dest[n-1] = '\0'; } while (0) | strncpy(dest, src, n-1); dest[n-1] = '\0'; } while (0) | |||
/* Return malloc-allocated concatenation of all NUL-terminated string | /* Return malloc-allocated concatenation of all NUL-terminated string | |||
* arguments, up to a terminating NULL. */ | * arguments, up to a terminating NULL. */ | |||
char *ne_concat(const char *str, ...); | char *ne_concat(const char *str, ...); | |||
#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) ((char) ((x) > 9 ? ((x) - 10 + 'a') : ((x) + '0'))) | #define NE_HEX2ASC(x) ((char) ((x) > 9 ? ((x) - 10 + 'a') : ((x) + '0'))) | |||
/* Wrapper for snprintf: always NUL-terminates returned buffer, and | ||||
* returns strlen(str). */ | ||||
size_t ne_snprintf(char *str, size_t size, const char *fmt, ...) | ||||
ne_attribute((format(printf, 3, 4))); | ||||
/* Wrapper for vsnprintf. */ | ||||
size_t ne_vsnprintf(char *str, size_t size, const char *fmt, va_list ap) | ||||
ne_attribute((format(printf, 3, 0))); | ||||
END_NEON_DECLS | END_NEON_DECLS | |||
#endif /* NE_STRING_H */ | #endif /* NE_STRING_H */ | |||
End of changes. 4 change blocks. | ||||
13 lines changed or deleted | 14 lines changed or added | |||
ne_uri.h | ne_uri.h | |||
---|---|---|---|---|
/* | /* | |||
HTTP URI handling | URI manipulation routines. | |||
Copyright (C) 1999-2002, Joe Orton <joe@manyfish.co.uk> | Copyright (C) 1999-2005, Joe Orton <joe@manyfish.co.uk> | |||
This library is free software; you can redistribute it and/or | This library is free software; you can redistribute it and/or | |||
modify it under the terms of the GNU Library General Public | modify it under the terms of the GNU Library General Public | |||
License as published by the Free Software Foundation; either | License as published by the Free Software Foundation; either | |||
version 2 of the License, or (at your option) any later version. | version 2 of the License, or (at your option) any later version. | |||
This library is distributed in the hope that it will be useful, | This library is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
Library General Public License for more details. | Library General Public License for more details. | |||
skipping to change at line 29 | skipping to change at line 29 | |||
*/ | */ | |||
#ifndef NE_URI_H | #ifndef NE_URI_H | |||
#define NE_URI_H | #define NE_URI_H | |||
#include "ne_defs.h" | #include "ne_defs.h" | |||
BEGIN_NEON_DECLS | BEGIN_NEON_DECLS | |||
/* Un-escapes a path. Returns malloc-allocated path on success, or | /* Return a copy of a path string with anything other than | |||
* NULL on an invalid %<HEX><HEX> sequence. */ | * "unreserved" and the forward-slash character percent-encoded | |||
char *ne_path_unescape(const char *uri); | * according to the URI encoding rules. Returns a malloc-allocated | |||
* string and never NULL. */ | ||||
char *ne_path_escape(const char *path); | ||||
/* Escapes the a path segment: returns malloc-allocated string on | /* Return a decoded copy of a percent-encoded path string. Returns | |||
* success, or NULL on malloc failure. */ | * malloc-allocated path on success, or NULL if the string contained | |||
char *ne_path_escape(const char *abs_path); | * any syntactically invalid percent-encoding sequences. */ | |||
char *ne_path_unescape(const char *epath); | ||||
/* Returns malloc-allocated parent of path, or NULL if path has no | /* Returns malloc-allocated parent of path, or NULL if path has no | |||
* parent (such as "/"). */ | * parent (such as "/"). */ | |||
char *ne_path_parent(const char *path); | char *ne_path_parent(const char *path); | |||
/* 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 */ | |||
skipping to change at line 64 | skipping to change at line 67 | |||
typedef struct { | typedef struct { | |||
char *scheme; | char *scheme; | |||
char *host; | char *host; | |||
unsigned 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. On successful or | |||
* are malloc'ed, structure should be free'd with uri_free on | * error return, all the 'char *' fields of *parsed are either set to | |||
* successful return. Any unspecified URI fields are set to NULL or 0 | * NULL, or point to malloc-allocated NUL-terminated strings. | |||
* appropriately in *parsed. */ | * ne_uri_free can be used to free the structure after use.*/ | |||
int ne_uri_parse(const char *uri, ne_uri *parsed); | int ne_uri_parse(const char *uri, ne_uri *parsed); | |||
/* Turns a URI structure back into a string. String is | /* Turns a URI structure back into a string. String is | |||
* malloc-allocated, and must be free'd by the caller. */ | * malloc-allocated, and must be freed by the caller. */ | |||
char *ne_uri_unparse(const ne_uri *uri); | char *ne_uri_unparse(const ne_uri *uri); | |||
/* Compares URIs u1 and u2, returns non-zero if they are found to be | /* Compares URIs u1 and u2, returns non-zero if they are found to be | |||
* non-equal. The sign of the return value is <0 if 'u1' is less than | * non-equal. The sign of the return value is <0 if 'u1' is less than | |||
* 'u2', or >0 if 'u2' is greater than 'u1'. */ | * 'u2', or >0 if 'u2' is greater than 'u1'. */ | |||
int ne_uri_cmp(const ne_uri *u1, const ne_uri *u2); | int ne_uri_cmp(const ne_uri *u1, const ne_uri *u2); | |||
/* Free URI object. */ | /* Frees any non-NULL fields of parsed URI structure *parsed. All | |||
* fields are then zero-initialized. */ | ||||
void ne_uri_free(ne_uri *parsed); | void ne_uri_free(ne_uri *parsed); | |||
END_NEON_DECLS | END_NEON_DECLS | |||
#endif /* NE_URI_H */ | #endif /* NE_URI_H */ | |||
End of changes. 6 change blocks. | ||||
14 lines changed or deleted | 18 lines changed or added | |||
ne_utils.h | ne_utils.h | |||
---|---|---|---|---|
/* | /* | |||
HTTP utility functions | HTTP utility functions | |||
Copyright (C) 1999-2002, Joe Orton <joe@manyfish.co.uk> | Copyright (C) 1999-2005, Joe Orton <joe@manyfish.co.uk> | |||
This library is free software; you can redistribute it and/or | This library is free software; you can redistribute it and/or | |||
modify it under the terms of the GNU Library General Public | modify it under the terms of the GNU Library General Public | |||
License as published by the Free Software Foundation; either | License as published by the Free Software Foundation; either | |||
version 2 of the License, or (at your option) any later version. | version 2 of the License, or (at your option) any later version. | |||
This library is distributed in the hope that it will be useful, | This library is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
Library General Public License for more details. | Library General Public License for more details. | |||
skipping to change at line 46 | skipping to change at line 46 | |||
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 library version is not of major version | /* Returns non-zero if library version is not of major version | |||
* 'major', or if minor version is not greater than or equal to | * 'major', or if minor version is not greater than or equal to | |||
* 'minor'. */ | * 'minor'. For neon versions with major == 0, all minor versions are | |||
* presumed to be incompatible. */ | ||||
int ne_version_match(int major, int minor); | int ne_version_match(int major, int minor); | |||
/* Returns non-zero if neon has support for SSL. */ | #define NE_FEATURE_SSL (1) /* SSL/TLS support */ | |||
int ne_supports_ssl(void); | #define NE_FEATURE_ZLIB (2) /* zlib compression in compress interface */ | |||
#define NE_FEATURE_IPV6 (3) /* IPv6 is supported in resolver */ | ||||
/* Use replacement snprintf's if trio is being used. */ | #define NE_FEATURE_LFS (4) /* large file support */ | |||
#ifdef NEON_TRIO | #define NE_FEATURE_SOCKS (5) /* SOCKSv5 support */ | |||
#define ne_snprintf trio_snprintf | ||||
#define ne_vsnprintf trio_vsnprintf | ||||
#else | ||||
#define ne_snprintf snprintf | ||||
#define ne_vsnprintf vsnprintf | ||||
#endif | ||||
#ifndef WIN32 | /* Returns non-zero if neon has support for given feature code | |||
#undef min | * NE_FEATURE_*. */ | |||
#define min(a,b) ((a)<(b)?(a):(b)) | int ne_has_support(int feature); | |||
#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. */ | |||
#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 */ | |||
End of changes. 4 change blocks. | ||||
17 lines changed or deleted | 11 lines changed or added | |||
ne_xml.h | ne_xml.h | |||
---|---|---|---|---|
/* | /* | |||
neon XML parser interface | neon XML parser interface | |||
Copyright (C) 1999-2003, Joe Orton <joe@manyfish.co.uk> | Copyright (C) 1999-2004, Joe Orton <joe@manyfish.co.uk> | |||
This library is free software; you can redistribute it and/or | This library is free software; you can redistribute it and/or | |||
modify it under the terms of the GNU Library General Public | modify it under the terms of the GNU Library General Public | |||
License as published by the Free Software Foundation; either | License as published by the Free Software Foundation; either | |||
version 2 of the License, or (at your option) any later version. | version 2 of the License, or (at your option) any later version. | |||
This library is distributed in the hope that it will be useful, | This library is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
Library General Public License for more details. | Library General Public License for more details. | |||
skipping to change at line 89 | skipping to change at line 89 | |||
ne_xml_parser *ne_xml_create(void); | ne_xml_parser *ne_xml_create(void); | |||
/* Push a new handler on the stack of parser 'p'. 'cdata' and/or | /* Push a new handler on the stack of parser 'p'. 'cdata' and/or | |||
* 'endelm' may be NULL; startelm must be non-NULL. */ | * 'endelm' may be NULL; startelm must be non-NULL. */ | |||
void ne_xml_push_handler(ne_xml_parser *p, | void ne_xml_push_handler(ne_xml_parser *p, | |||
ne_xml_startelm_cb *startelm, | ne_xml_startelm_cb *startelm, | |||
ne_xml_cdata_cb *cdata, | ne_xml_cdata_cb *cdata, | |||
ne_xml_endelm_cb *endelm, | ne_xml_endelm_cb *endelm, | |||
void *userdata); | void *userdata); | |||
/* Returns non-zero if the parse was valid, zero if it failed (e.g., | /* ne_xml_failed returns non-zero if there was an error during | |||
* any of the callbacks failed, the XML was not well-formed, etc). | * parsing, or zero if the parse completed successfully. The return | |||
* Use ne_xml_get_error to retrieve the error message if it failed. */ | * value is equal to that of the last ne_xml_parse call for this | |||
int ne_xml_valid(ne_xml_parser *p); | * parser. */ | |||
int ne_xml_failed(ne_xml_parser *p); | ||||
/* Set error string for parser: the string may be truncated. */ | ||||
void ne_xml_set_error(ne_xml_parser *p, const char *msg); | ||||
/* Return the error string (never NULL). After ne_xml_failed returns | ||||
* >0, this will describe the parse error. Otherwise it will be a | ||||
* default error string. */ | ||||
const char *ne_xml_get_error(ne_xml_parser *p); | ||||
/* Destroy the parser object. */ | /* Destroy the parser object. */ | |||
void ne_xml_destroy(ne_xml_parser *p); | void ne_xml_destroy(ne_xml_parser *p); | |||
/* Parse the given block of input of length len. Block does not need | /* Parse the given block of input of length len. Parser must be | |||
* to be NUL-terminated. */ | * called with len=0 to signify the end of the document (for that | |||
void ne_xml_parse(ne_xml_parser *p, const char *block, size_t len); | * case, the block argument is ignored). Returns zero on success, or | |||
* non-zero on error: for an XML syntax error, a positive number is | ||||
* returned; if parsing is aborted by a caller-supplied callback, that | ||||
* callback's return value is returned. */ | ||||
int ne_xml_parse(ne_xml_parser *p, const char *block, size_t len); | ||||
/* As above, casting (ne_xml_parser *)userdata internally. | /* As above, casting (ne_xml_parser *)userdata internally. | |||
* (This function can be passed to ne_add_response_body_reader) */ | * (This function can be passed to ne_add_response_body_reader) */ | |||
void ne_xml_parse_v(void *userdata, const char *block, size_t len); | int ne_xml_parse_v(void *userdata, const char *block, size_t len); | |||
/* Return current parse line for errors */ | /* Return current parse line for errors */ | |||
int ne_xml_currentline(ne_xml_parser *p); | int ne_xml_currentline(ne_xml_parser *p); | |||
/* Set error string for parser. */ | ||||
void ne_xml_set_error(ne_xml_parser *p, const char *msg); | ||||
/* Return the error string for the parser and never NULL. */ | ||||
const char *ne_xml_get_error(ne_xml_parser *p); | ||||
/* From a start_element callback which was passed 'attrs' using given | /* From a start_element callback which was passed 'attrs' using given | |||
* parser, return attribute of given name and namespace. If nspace is | * parser, return attribute of given name and namespace. If nspace is | |||
* NULL, no namespace resolution is performed. */ | * NULL, no namespace resolution is performed. */ | |||
const char *ne_xml_get_attr(ne_xml_parser *parser, | const char *ne_xml_get_attr(ne_xml_parser *parser, | |||
const char **attrs, const char *nspace, | const char **attrs, const char *nspace, | |||
const char *name); | const char *name); | |||
/* Return the encoding of the document being parsed. May return NULL | /* Return the encoding of the document being parsed. May return NULL | |||
* if no encoding is defined or if the XML declaration has not yet | * if no encoding is defined or if the XML declaration has not yet | |||
* been parsed. */ | * been parsed. */ | |||
End of changes. 5 change blocks. | ||||
15 lines changed or deleted | 22 lines changed or added | |||