* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
- * $Id: shttpd.h,v 1.3 2007/04/11 13:01:53 drozd Exp $
+ * $Id: shttpd.h,v 1.9 2008/02/13 20:44:32 drozd Exp $
*/
#ifndef SHTTPD_HEADER_INCLUDED
* 4. for POST requests, it must process the incoming data (in.buf) of length
* 'in.len', and set 'in.num_bytes', which is how many bytes of POST
* data is read and can be discarded by SHTTPD.
+ * 5. If callback allocates arg->state, to keep state, it must deallocate it
+ * at the end of coonection SHTTPD_CONNECTION_ERROR or SHTTPD_END_OF_OUTPUT
*/
typedef void (*shttpd_callback_t)(struct shttpd_arg *);
/*
- * shttpd_init Initialize shttpd context. Parameters: configuration
- * file name (may be NULL), then NULL-terminated
- * sequence of pairs "option_name", "option_value".
- * shttpd_init2 Same as shttpd_init, but the list of option/value
- * pairs is passed in arrays
+ * shttpd_init Initialize shttpd context.
+ * shttpd_set_option Set new value for option.
* shttpd_fini Dealocate the context
* shttpd_register_uri Setup the callback function for specified URL.
- * shttpd_protect_uri Associate authorization file with an URL.
- * shttpd_add_mime_type Add mime type
* shtppd_listen Setup a listening socket in the SHTTPD context
* shttpd_poll Do connections processing
* shttpd_version return string with SHTTPD version
- * shttpd_get_var Return POST/GET variable value for given variable name.
+ * shttpd_get_var Fetch POST/GET variable value by name. Return value len
* shttpd_get_header return value of the specified HTTP header
* shttpd_get_env return string values for the following
* pseudo-variables: "REQUEST_METHOD", "REQUEST_URI",
struct shttpd_ctx;
-struct shttpd_ctx *shttpd_init(const char *config_file, ...);
-struct shttpd_ctx *shttpd_init2(const char *config_file,
- char *names[], char *values[], size_t num_options);
+struct shttpd_ctx *shttpd_init(void);
+void shttpd_set_option(struct shttpd_ctx *, const char *opt, const char *val);
void shttpd_fini(struct shttpd_ctx *);
-void shttpd_add_mime_type(struct shttpd_ctx *,
- const char *ext, const char *mime);
int shttpd_listen(struct shttpd_ctx *ctx, int port, int is_ssl);
-void shttpd_register_uri(struct shttpd_ctx *ctx,
- const char *uri, shttpd_callback_t callback, void *user_data);
-void shttpd_protect_uri(struct shttpd_ctx *ctx,
- const char *uri, const char *file);
+void shttpd_register_uri(struct shttpd_ctx *ctx, const char *uri,
+ shttpd_callback_t callback, void *const user_data);
void shttpd_poll(struct shttpd_ctx *, int milliseconds);
const char *shttpd_version(void);
int shttpd_get_var(const char *var, const char *buf, int buf_len,
char *value, int value_len);
-const char *shttpd_get_header(struct shttpd_arg *, const char *);
-const char *shttpd_get_env(struct shttpd_arg *, const char *);
+const char *shttpd_get_header(struct shttpd_arg *, const char *header_name);
+const char *shttpd_get_env(struct shttpd_arg *, const char *name);
void shttpd_get_http_version(struct shttpd_arg *,
unsigned long *major, unsigned long *minor);
size_t shttpd_printf(struct shttpd_arg *, const char *fmt, ...);
void shttpd_handle_error(struct shttpd_ctx *ctx, int status,
- shttpd_callback_t func, void *data);
+ shttpd_callback_t func, void *const data);
void shttpd_register_ssi_func(struct shttpd_ctx *ctx, const char *name,
- shttpd_callback_t func, void *user_data);
+ shttpd_callback_t func, void *const user_data);
/*
* The following three functions are for applications that need to
* pool for the idle thread by means of shttpd_active(), and add new
* connection to the context by means of shttpd_add().
*/
-void shttpd_add_socket(struct shttpd_ctx *, int sock);
+void shttpd_add_socket(struct shttpd_ctx *, int sock, int is_ssl);
int shttpd_accept(int lsn_sock, int milliseconds);
int shttpd_active(struct shttpd_ctx *);