Commit fffb54e2 authored by Marko Mikulicic's avatar Marko Mikulicic Committed by Cesanta Bot

Implementing MG interfaces

PUBLISHED_FROM=46496c2d5340a0bbe4fe1c6c9ff187bc65d2d35f
parent 8bf3bd48
...@@ -15,6 +15,7 @@ items: ...@@ -15,6 +15,7 @@ items:
- { name: mg_enable_multithreading.md } - { name: mg_enable_multithreading.md }
- { name: mg_mgr_free.md } - { name: mg_mgr_free.md }
- { name: mg_mgr_init.md } - { name: mg_mgr_init.md }
- { name: mg_mgr_init_opt.md }
- { name: mg_mgr_poll.md } - { name: mg_mgr_poll.md }
- { name: mg_next.md } - { name: mg_next.md }
- { name: mg_printf.md } - { name: mg_printf.md }
...@@ -31,6 +32,7 @@ items: ...@@ -31,6 +32,7 @@ items:
- { name: struct_mg_connect_opts.md } - { name: struct_mg_connect_opts.md }
- { name: struct_mg_connection.md } - { name: struct_mg_connection.md }
- { name: struct_mg_mgr.md } - { name: struct_mg_mgr.md }
- { name: struct_mg_mgr_init_opts.md }
- { name: struct_mg_multithreading_opts.md } - { name: struct_mg_multithreading_opts.md }
--- ---
......
...@@ -3,7 +3,8 @@ title: "mg_event_handler_t" ...@@ -3,7 +3,8 @@ title: "mg_event_handler_t"
decl_name: "mg_event_handler_t" decl_name: "mg_event_handler_t"
symbol_kind: "typedef" symbol_kind: "typedef"
signature: | signature: |
typedef void (*mg_event_handler_t)(struct mg_connection *nc, int ev, void *ev_data); typedef void (*mg_event_handler_t)(struct mg_connection *nc, int ev,
void *ev_data);
--- ---
Callback function (event handler) prototype. Must be defined by the user. Callback function (event handler) prototype. Must be defined by the user.
......
---
title: "mg_mgr_init_opt()"
decl_name: "mg_mgr_init_opt"
symbol_kind: "func"
signature: |
void mg_mgr_init_opt(struct mg_mgr *mgr, void *user_data,
struct mg_mgr_init_opts opts);
---
Like `mg_mgr_init` but with more options.
Notably, this allows you to create a manger and choose
dynamically which networking interface implementation to use.
...@@ -42,6 +42,7 @@ signature: | ...@@ -42,6 +42,7 @@ signature: |
} priv_1; /* Used by mg_enable_multithreading() */ } priv_1; /* Used by mg_enable_multithreading() */
void *priv_2; /* Used by mg_enable_multithreading() */ void *priv_2; /* Used by mg_enable_multithreading() */
void *mgr_data; /* Implementation-specific event manager's data. */ void *mgr_data; /* Implementation-specific event manager's data. */
struct mg_iface *iface;
unsigned long flags; unsigned long flags;
/* Flags set by Mongoose */ /* Flags set by Mongoose */
#define MG_F_LISTENING (1 << 0) /* This connection is listening */ #define MG_F_LISTENING (1 << 0) /* This connection is listening */
......
...@@ -12,7 +12,8 @@ signature: | ...@@ -12,7 +12,8 @@ signature: |
sock_t ctl[2]; /* Socketpair for mg_broadcast() */ sock_t ctl[2]; /* Socketpair for mg_broadcast() */
#endif #endif
void *user_data; /* User data */ void *user_data; /* User data */
void *mgr_data; /* Implementation-specific event manager's data. */ int num_ifaces;
struct mg_iface **ifaces; /* network interfaces */
#if MG_ENABLE_JAVASCRIPT #if MG_ENABLE_JAVASCRIPT
struct v7 *v7; struct v7 *v7;
#endif #endif
......
---
title: "struct mg_mgr_init_opts"
decl_name: "struct mg_mgr_init_opts"
symbol_kind: "struct"
signature: |
struct mg_mgr_init_opts {
struct mg_iface_vtable *main_iface;
int num_ifaces;
struct mg_iface_vtable **ifaces;
};
---
Optional parameters to `mg_mgr_init_opt()`.
If `main_iface` is not NULL, it will be used as the main interface in the
default interface set. The pointer will be free'd by `mg_mgr_free`.
Otherwise, the main interface will be autodetected based on the current
platform.
If `num_ifaces` is 0 and `ifaces` is NULL, the default interface set will be
used.
This is an advanced option, as it requires you to construct a full interface
set, including special networking interfaces required by some optional
features such as TCP tunneling. Memory backing `ifaces` and each of the
`num_ifaces` pointers it contains will be reclaimed by `mg_mgr_free`.
This diff is collapsed.
This diff is collapsed.
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