Skip to content
Snippets Groups Projects
Commit 7bed7ff4 authored by Dmitry Frank's avatar Dmitry Frank Committed by Marko Mikulicic
Browse files

Docs are generated for Mongoose

Comments in headers are changed a bit: removed adoc-specific stuff,
markdown is used instead

PUBLISHED_FROM=9242cce85cc52a47a197d377e7e23804721a6bb5
parent d38b0dbf
No related branches found
No related tags found
No related merge requests found
Showing
with 377 additions and 0 deletions
---
title: "struct websocket_message"
decl_name: "struct websocket_message"
symbol_kind: "struct"
signature: |
struct websocket_message {
unsigned char *data;
size_t size;
unsigned char flags;
};
---
WebSocket message
{
"items": [
{
"type": "section",
"name": "mbuf.h"
},
{
"type": "section",
"name": "net.h"
},
{
"type": "section",
"name": "http.h"
},
{
"type": "section",
"name": "json-rpc.h"
},
{
"type": "section",
"name": "dns.h"
},
{
"type": "section",
"name": "dns-server.h"
},
{
"type": "section",
"name": "mqtt.h"
},
{
"type": "section",
"name": "mqtt-broker.h"
},
{
"type": "section",
"name": "coap.h"
},
{
"type": "section",
"name": "util.h"
}
]
}
---
title: "JSON-RPC"
symbol_kind: "intro"
decl_name: "json-rpc.h"
---
{
"items": [
{
"type": "markdown",
"name": "intro.md"
},
{
"type": "markdown",
"name": "mg_rpc_parse_reply.md"
},
{
"type": "markdown",
"name": "mg_rpc_create_request.md"
},
{
"type": "markdown",
"name": "mg_rpc_create_reply.md"
},
{
"type": "markdown",
"name": "mg_rpc_create_error.md"
},
{
"type": "markdown",
"name": "mg_rpc_create_std_error.md"
},
{
"type": "markdown",
"name": "mg_rpc_dispatch.md"
},
{
"type": "markdown",
"name": "struct_mg_rpc_request.md"
},
{
"type": "markdown",
"name": "struct_mg_rpc_reply.md"
},
{
"type": "markdown",
"name": "struct_mg_rpc_error.md"
}
]
}
---
title: "mg_rpc_create_error()"
decl_name: "mg_rpc_create_error"
symbol_kind: "func"
signature: |
int mg_rpc_create_error(char *buf, int len, struct mg_rpc_request *req,
int code, const char *message, const char *fmt, ...);
---
Create JSON-RPC error reply in a given buffer.
Return length of the error, which
can be larger then `len` that indicates an overflow.
`fmt` format string should conform to `json_emit()` API,
see https://github.com/cesanta/frozen
---
title: "mg_rpc_create_reply()"
decl_name: "mg_rpc_create_reply"
symbol_kind: "func"
signature: |
int mg_rpc_create_reply(char *buf, int len, const struct mg_rpc_request *req,
const char *result_fmt, ...);
---
Create JSON-RPC reply in a given buffer.
Return length of the reply, which
can be larger then `len` that indicates an overflow.
`result_fmt` format string should conform to `json_emit()` API,
see https://github.com/cesanta/frozen
---
title: "mg_rpc_create_request()"
decl_name: "mg_rpc_create_request"
symbol_kind: "func"
signature: |
int mg_rpc_create_request(char *buf, int len, const char *method,
const char *id, const char *params_fmt, ...);
---
Create JSON-RPC request in a given buffer.
Return length of the request, which
can be larger then `len` that indicates an overflow.
`params_fmt` format string should conform to `json_emit()` API,
see https://github.com/cesanta/frozen
---
title: "mg_rpc_create_std_error()"
decl_name: "mg_rpc_create_std_error"
symbol_kind: "func"
signature: |
int mg_rpc_create_std_error(char *buf, int len, struct mg_rpc_request *req,
int code);
---
Create JSON-RPC error in a given buffer.
Return length of the error, which
can be larger then `len` that indicates an overflow. See
JSON_RPC_*_ERROR definitions for standard error values:
- `#define JSON_RPC_PARSE_ERROR (-32700)`
- `#define JSON_RPC_INVALID_REQUEST_ERROR (-32600)`
- `#define JSON_RPC_METHOD_NOT_FOUND_ERROR (-32601)`
- `#define JSON_RPC_INVALID_PARAMS_ERROR (-32602)`
- `#define JSON_RPC_INTERNAL_ERROR (-32603)`
- `#define JSON_RPC_SERVER_ERROR (-32000)`
---
title: "mg_rpc_dispatch()"
decl_name: "mg_rpc_dispatch"
symbol_kind: "func"
signature: |
int mg_rpc_dispatch(const char *buf, int, char *dst, int dst_len,
const char **methods, mg_rpc_handler_t *handlers);
---
Dispatches a JSON-RPC request.
Parses JSON-RPC request contained in `buf`, `len`.
Then, dispatches the request to the correct handler method.
Valid method names should be specified in NULL
terminated array `methods`, and corresponding handlers in `handlers`.
Result is put in `dst`, `dst_len`. Return: length of the result, which
can be larger then `dst_len` that indicates an overflow.
Overflown bytes are not written to the buffer.
If method is not found, an error is automatically generated.
---
title: "mg_rpc_parse_reply()"
decl_name: "mg_rpc_parse_reply"
symbol_kind: "func"
signature: |
int mg_rpc_parse_reply(const char *buf, int len, struct json_token *toks,
int max_toks, struct mg_rpc_reply *,
struct mg_rpc_error *);
---
Parse JSON-RPC reply contained in `buf`, `len` into JSON tokens array
`toks`, `max_toks`. If buffer contains valid reply, `reply` structure is
populated. The result of RPC call is located in `reply.result`. On error,
`error` structure is populated. Returns: the result of calling
`parse_json(buf, len, toks, max_toks)`:
On success, an offset inside `json_string` is returned
where parsing has finished. On failure, a negative number is
returned, one of:
- `#define JSON_STRING_INVALID -1`
- `#define JSON_STRING_INCOMPLETE -2`
- `#define JSON_TOKEN_ARRAY_TOO_SMALL -3`
---
title: "struct mg_rpc_error"
decl_name: "struct mg_rpc_error"
symbol_kind: "struct"
signature: |
struct mg_rpc_error {
struct json_token *message; /* Whole RPC message */
struct json_token *id; /* Message ID */
struct json_token *error_code; /* error.code */
struct json_token *error_message; /* error.message */
struct json_token *error_data; /* error.data, can be NULL */
};
---
JSON-RPC error
---
title: "struct mg_rpc_reply"
decl_name: "struct mg_rpc_reply"
symbol_kind: "struct"
signature: |
struct mg_rpc_reply {
struct json_token *message; /* Whole RPC message */
struct json_token *id; /* Message ID */
struct json_token *result; /* Remote call result */
};
---
JSON-RPC response
---
title: "struct mg_rpc_request"
decl_name: "struct mg_rpc_request"
symbol_kind: "struct"
signature: |
struct mg_rpc_request {
struct json_token *message; /* Whole RPC message */
struct json_token *id; /* Message ID */
struct json_token *method; /* Method name */
struct json_token *params; /* Method params */
};
---
JSON-RPC request
---
title: "Memory Buffers"
symbol_kind: "intro"
decl_name: "mbuf.h"
---
Mbufs are mutable/growing memory buffers, like C++ strings.
Mbuf can append data to the end of a buffer, or insert data into arbitrary
position in the middle of a buffer. The buffer grows automatically when
needed.
{
"items": [
{
"type": "markdown",
"name": "intro.md"
},
{
"type": "markdown",
"name": "mbuf_init.md"
},
{
"type": "markdown",
"name": "mbuf_free.md"
},
{
"type": "markdown",
"name": "mbuf_append.md"
},
{
"type": "markdown",
"name": "mbuf_insert.md"
},
{
"type": "markdown",
"name": "mbuf_remove.md"
},
{
"type": "markdown",
"name": "mbuf_resize.md"
},
{
"type": "markdown",
"name": "mbuf_trim.md"
},
{
"type": "markdown",
"name": "struct_mbuf.md"
}
]
}
---
title: "mbuf_append()"
decl_name: "mbuf_append"
symbol_kind: "func"
signature: |
size_t mbuf_append(struct mbuf *, const void *data, size_t data_size);
---
Appends data to the Mbuf.
Return the number of bytes appended, or 0 if out of memory.
---
title: "mbuf_free()"
decl_name: "mbuf_free"
symbol_kind: "func"
signature: |
void mbuf_free(struct mbuf *);
---
Free the space allocated for the mbuffer and resets the mbuf structure.
---
title: "mbuf_init()"
decl_name: "mbuf_init"
symbol_kind: "func"
signature: |
void mbuf_init(struct mbuf *, size_t initial_capacity);
---
Initialize an Mbuf.
`initial_capacity` specifies the initial capacity of the mbuf.
---
title: "mbuf_insert()"
decl_name: "mbuf_insert"
symbol_kind: "func"
signature: |
size_t mbuf_insert(struct mbuf *, size_t, const void *, size_t);
---
Insert data at a specified offset in the Mbuf.
Existing data will be shifted forwards and the buffer will
be grown if necessary.
Return the number of bytes inserted.
---
title: "mbuf_remove()"
decl_name: "mbuf_remove"
symbol_kind: "func"
signature: |
void mbuf_remove(struct mbuf *, size_t data_size);
---
Remove `data_size` bytes from the beginning of the buffer.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment