From 1da098671e3621cde0c37051701a39a5f372ded7 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Sat, 19 Oct 2013 14:07:46 -0700 Subject: [PATCH] Moved docstrings to API.md --- docs/API.md | 31 ++++++++++++++++++++++++------- mongoose.h | 21 +-------------------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/docs/API.md b/docs/API.md index e1d4171d..023bd3c4 100644 --- a/docs/API.md +++ b/docs/API.md @@ -33,7 +33,6 @@ Here is a list of well-commented embedding examples: # API Reference -## mg\_start() struct mg_context *mg_start(const char **configuration_options int (*event_handler_func)(struct mg_event *), void *user_data); @@ -58,8 +57,6 @@ used to handle incoming requests. `SIGCHLD` handler must be set up to reap CGI zombie processes. -## mg\_stop() - void mg_stop(struct mg_context *); Stop the web server. This function blocks until all Mongoose @@ -129,8 +126,6 @@ initialization. Return value is ignored by Mongoose. Called when Mongoose is about to terminate a thread. Used to clean up the state initialized by `MG_THREAD_BEGIN` handling. Return value is ignored. -## mg\_get\_option() - const char *mg_get_option(const struct mg_context *ctx, const char *name); Get the value of particular configuration parameter. The value returned is @@ -139,8 +134,6 @@ given parameter name is not valid, NULL is returned. For valid names, return value is guaranteed to be non-NULL. If parameter is not set, zero-length string is returned. -## mg\_get\_valid\_option\_names() - const char **mg_get_valid_option_names(void); Return array of strings that represent valid configuration options. For each @@ -148,6 +141,30 @@ option, option name and default value is returned, i.e. the number of entries in the array equals to number_of_options x 2. Array is NULL terminated. + int mg_modify_passwords_file(const char *passwords_file_name, + const char *domain, + const char *user, + const char *password); + +Add, edit or delete the entry in the passwords file. +This function allows an application to manipulate .htpasswd files on the +fly by adding, deleting and changing user records. This is one of the +several ways of implementing authentication on the server side. For another, +cookie-based way please refer to the examples/chat.c in the source tree. +If password is not NULL, entry is added (or modified if already exists). +If password is NULL, entry is deleted. +Return: 1 on success, 0 on error. + + + int mg_write(struct mg_connection *, const void *buf, int len); + +Send data to the client. This function attempts to send all requested data, +unlike `write()` standard library call, which might send only a portion of +requested data. +Return: number of bytes written to the client. If return value is less then +`len`, client has closed the connection. + + ## Embedding Examples The common pattern is to handle `MG_REQUEST_BEGIN` and serve static files diff --git a/mongoose.h b/mongoose.h index 2e80b214..c7098b17 100644 --- a/mongoose.h +++ b/mongoose.h @@ -72,32 +72,13 @@ void mg_stop(struct mg_context *); void mg_websocket_handshake(struct mg_connection *); int mg_websocket_read(struct mg_connection *, int *bits, char **data); + const char *mg_get_option(const struct mg_context *ctx, const char *name); const char **mg_get_valid_option_names(void); - - -// Add, edit or delete the entry in the passwords file. -// -// This function allows an application to manipulate .htpasswd files on the -// fly by adding, deleting and changing user records. This is one of the -// several ways of implementing authentication on the server side. For another, -// cookie-based way please refer to the examples/chat.c in the source tree. -// -// If password is not NULL, entry is added (or modified if already exists). -// If password is NULL, entry is deleted. -// -// Return: -// 1 on success, 0 on error. int mg_modify_passwords_file(const char *passwords_file_name, const char *domain, const char *user, const char *password); - -// Send data to the client. -// Return: -// 0 when the connection has been closed -// -1 on error -// >0 number of bytes written on success int mg_write(struct mg_connection *, const void *buf, int len);