Commit 1da09867 authored by Sergey Lyubka's avatar Sergey Lyubka

Moved docstrings to API.md

parent f852a4db
...@@ -33,7 +33,6 @@ Here is a list of well-commented embedding examples: ...@@ -33,7 +33,6 @@ Here is a list of well-commented embedding examples:
# API Reference # API Reference
## mg\_start()
struct mg_context *mg_start(const char **configuration_options struct mg_context *mg_start(const char **configuration_options
int (*event_handler_func)(struct mg_event *), int (*event_handler_func)(struct mg_event *),
void *user_data); void *user_data);
...@@ -58,8 +57,6 @@ used to handle incoming requests. ...@@ -58,8 +57,6 @@ used to handle incoming requests.
`SIGCHLD` handler must be set up to reap CGI zombie processes. `SIGCHLD` handler must be set up to reap CGI zombie processes.
## mg\_stop()
void mg_stop(struct mg_context *); void mg_stop(struct mg_context *);
Stop the web server. This function blocks until all Mongoose Stop the web server. This function blocks until all Mongoose
...@@ -129,8 +126,6 @@ initialization. Return value is ignored by 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 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. 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); const char *mg_get_option(const struct mg_context *ctx, const char *name);
Get the value of particular configuration parameter. The value returned is 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 ...@@ -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 value is guaranteed to be non-NULL. If parameter is not set, zero-length string
is returned. is returned.
## mg\_get\_valid\_option\_names()
const char **mg_get_valid_option_names(void); const char **mg_get_valid_option_names(void);
Return array of strings that represent valid configuration options. For each 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 ...@@ -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. 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 ## Embedding Examples
The common pattern is to handle `MG_REQUEST_BEGIN` and serve static files The common pattern is to handle `MG_REQUEST_BEGIN` and serve static files
......
...@@ -72,32 +72,13 @@ void mg_stop(struct mg_context *); ...@@ -72,32 +72,13 @@ void mg_stop(struct mg_context *);
void mg_websocket_handshake(struct mg_connection *); void mg_websocket_handshake(struct mg_connection *);
int mg_websocket_read(struct mg_connection *, int *bits, char **data); 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_option(const struct mg_context *ctx, const char *name);
const char **mg_get_valid_option_names(void); 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, int mg_modify_passwords_file(const char *passwords_file_name,
const char *domain, const char *domain,
const char *user, const char *user,
const char *password); 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); int mg_write(struct mg_connection *, const void *buf, int len);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment