mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-26 22:41:03 +08:00
Make mg_mk_str take NULL, rename MG_STR MG_MK_STR
PUBLISHED_FROM=77f24c29667ca2aed3ad8a5102d7e1264f84228b
This commit is contained in:
parent
cf48c7280a
commit
a68d3d63b2
68
README.md
68
README.md
@ -1,4 +1,4 @@
|
||||
# <img src="http://www.cesanta.com/hubfs/www.cesanta.com/Images/mongoose_library.png" width="64" height="64"> Mongoose - Embedded Web Server / Embedded Networking Library
|
||||
# <img src="http://www.cesanta.com/hubfs/www.cesanta.com/Images/mongoose_library.png" width="64" height="64"> Mongoose - Embedded Web Server
|
||||
|
||||
![](https://img.shields.io/badge/license-GPL_2-green.svg "License")
|
||||
|
||||
@ -14,19 +14,13 @@ Mongoose helps developers to manage the complexity of network programming
|
||||
and let them concentrate on the logic, saving time and money.
|
||||
|
||||
- [Download Mongoose Source Code here](http://hubs.ly/H01bWvx0)
|
||||
- [Check our latest releases] (https://github.com/cesanta/mongoose/releases)
|
||||
- [Ask questions on support forum](http://forum.cesanta.com/index.php?p=/categories/mongoose)
|
||||
- [Read User Guide and API reference](https://docs.cesanta.com/mongoose)
|
||||
- [Study mongoose example code](https://github.com/cesanta/mongoose/tree/master/examples)
|
||||
|
||||
> Nothing overdone. Nothing less. So unbelievably easy to use.
|
||||
> Just how good software should be! -- Pritin Tyagaraj, SAP
|
||||
|
||||
If you are looking for a complete IoT platform with firmware and cloud compotent, check out [Smart.js.] (https://github.com/cesanta/smart.js)
|
||||
|
||||
# Support
|
||||
- [Support Forum - Ask your technical questions here] (http://forum.cesanta.com/index.php?p=/categories/smart-js)
|
||||
- [Chat - Visit www.cesanta.com for our live chat] (http://www.cesanta.com)
|
||||
- [Commercial one-to-one support - Available to all commercial license holders] (https://www.cesanta.com/services-support)
|
||||
|
||||
# Features
|
||||
|
||||
@ -38,7 +32,7 @@ If you are looking for a complete IoT platform with firmware and cloud compotent
|
||||
* Builtin protocols:
|
||||
- plain TCP, plain UDP, SSL/TLS (over TCP, one-way or two-way)
|
||||
- HTTP client, HTTP server
|
||||
- WebSocket client, WebSocket server
|
||||
- Websocket client, Websocket server
|
||||
- JSON-RPC client, JSON-RPC server
|
||||
- MQTT client, MQTT broker
|
||||
- CoAP client, CoAP server
|
||||
@ -49,16 +43,7 @@ If you are looking for a complete IoT platform with firmware and cloud compotent
|
||||
[mongoose.c](https://raw.githubusercontent.com/cesanta/mongoose/master/mongoose.c) and
|
||||
[mongoose.h](https://raw.githubusercontent.com/cesanta/mongoose/master/mongoose.h)
|
||||
files to your build tree
|
||||
|
||||
# Licensing
|
||||
|
||||
Mongoose is released under commercial and [GNU GPL v.2](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) open source licenses.
|
||||
|
||||
Commercial Projects:
|
||||
Once your project becomes commercialised GPLv2 licensing dictates that you need to either open your source fully or purchase a commercial license. Cesanta offer full, royalty-free commercial licenses without any GPL restrictions. If your needs require a custom license, we’d be happy to work on a solution with you. [Contact us for pricing.] (https://www.cesanta.com/contact)
|
||||
|
||||
Prototyping:
|
||||
While your project is still in prototyping stage and not for sale, you can use Mongoose’s open source code without license restrictions.
|
||||
* Extensively tested and production-ready, trusted by many blue chip businesses
|
||||
|
||||
# Dashboard Example
|
||||
|
||||
@ -73,6 +58,49 @@ the functionality:
|
||||
|
||||
# Contributions
|
||||
|
||||
People who have agreed to the [Cesanta CLA] (https://docs.cesanta.com/contributors_la.shtml) can make contributions. Note that the CLA isn't a copyright assigment but rather a copyright license. You retain the copyright on your contributions.
|
||||
People who have agreed to the
|
||||
[Cesanta CLA](https://docs.cesanta.com/contributors_la.shtml)
|
||||
can make contributions. Note that the CLA isn't a copyright
|
||||
_assigment_ but rather a copyright _license_.
|
||||
You retain the copyright on your contributions.
|
||||
|
||||
# Licensing
|
||||
|
||||
You are using Mongoose under
|
||||
[GPLv2](http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
|
||||
and until you commercialize your
|
||||
application, can continue to use Mongoose free of charge.
|
||||
|
||||
Once you commercialize your product, in order to comply with GPLv2
|
||||
you need to either open the source code of your product fully or
|
||||
alternatively purchase a commercial license.
|
||||
We offer [three levels of commercial licensing](https://www.cesanta.com/products):
|
||||
|
||||
- Mongoose Lite: cross platform integration, SSL/TLS, HTTP support
|
||||
- Mongoose: Mongoose Lite + HTTP CGI, HTTP SSI, HTTP Digest Auth,
|
||||
WebSocket support
|
||||
- Mongoose Premium: Mongoose + Plain TCP, UDP, JSON-RPC, MQTT, DNS,
|
||||
CoAP support
|
||||
|
||||
|
||||
[Enquire about commercial licensing here](https://www.cesanta.com/contact)
|
||||
|
||||
# Mongoose Binary
|
||||
|
||||
This is our easy to use web server for web developers (PHP, Ruby, Python, etc)
|
||||
and web designers. Available in three editions to suit your needs: free, pro
|
||||
(USD 5) and dev edition (from USD 8). To install, simply download, double-click
|
||||
to start and run browser - that's all!
|
||||
|
||||
[Download Mongoose Binary here](https://www.cesanta.com/products#binary)
|
||||
|
||||
# Other products by Cesanta
|
||||
|
||||
- [Smart.js](https://github.com/cesanta/smart.js) -
|
||||
Generic, hardware independent, full-stack IoT software platform
|
||||
- [V7](https://github.com/cesanta/v7) - Embedded JavaScript engine
|
||||
- [Frozen](https://github.com/cesanta/frozen) - JSON parser and generator
|
||||
- [SLRE](https://github.com/cesanta/slre) - Super Light Regular Expression
|
||||
library
|
||||
|
||||
[![Analytics](https://ga-beacon.appspot.com/UA-42732794-5/project-page)](https://github.com/cesanta/mongoose)
|
||||
|
@ -10,9 +10,9 @@ static struct mg_serve_http_opts s_http_server_opts;
|
||||
static int s_sig_num = 0;
|
||||
static void *s_db_handle = NULL;
|
||||
static const char *s_db_path = "api_server.db";
|
||||
static const struct mg_str s_get_method = MG_STR("GET");
|
||||
static const struct mg_str s_put_method = MG_STR("PUT");
|
||||
static const struct mg_str s_delele_method = MG_STR("DELETE");
|
||||
static const struct mg_str s_get_method = MG_MK_STR("GET");
|
||||
static const struct mg_str s_put_method = MG_MK_STR("PUT");
|
||||
static const struct mg_str s_delele_method = MG_MK_STR("DELETE");
|
||||
|
||||
static void signal_handler(int sig_num) {
|
||||
signal(sig_num, signal_handler);
|
||||
@ -28,7 +28,7 @@ static int is_equal(const struct mg_str *s1, const struct mg_str *s2) {
|
||||
}
|
||||
|
||||
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
|
||||
static const struct mg_str api_prefix = MG_STR("/api/v1");
|
||||
static const struct mg_str api_prefix = MG_MK_STR("/api/v1");
|
||||
struct http_message *hm = (struct http_message *) ev_data;
|
||||
struct mg_str key;
|
||||
|
||||
|
11
mongoose.c
11
mongoose.c
@ -5472,11 +5472,11 @@ static void do_ssi_call(struct mg_connection *nc, char *tag) {
|
||||
static void send_ssi_file(struct mg_connection *nc, const char *path, FILE *fp,
|
||||
int include_level,
|
||||
const struct mg_serve_http_opts *opts) {
|
||||
static const struct mg_str btag = MG_STR("<!--#");
|
||||
static const struct mg_str d_include = MG_STR("include");
|
||||
static const struct mg_str d_call = MG_STR("call");
|
||||
static const struct mg_str btag = MG_MK_STR("<!--#");
|
||||
static const struct mg_str d_include = MG_MK_STR("include");
|
||||
static const struct mg_str d_call = MG_MK_STR("call");
|
||||
#ifndef MG_DISABLE_POPEN
|
||||
static const struct mg_str d_exec = MG_STR("exec");
|
||||
static const struct mg_str d_exec = MG_MK_STR("exec");
|
||||
#endif
|
||||
char buf[BUFSIZ], *p = buf + btag.len; /* p points to SSI directive */
|
||||
int ch, offset, len, in_ssi_tag;
|
||||
@ -7808,7 +7808,8 @@ int mg_match_prefix(const char *pattern, int pattern_len, const char *str) {
|
||||
}
|
||||
|
||||
struct mg_str mg_mk_str(const char *s) {
|
||||
struct mg_str ret = {s, strlen(s)};
|
||||
struct mg_str ret = {s, 0};
|
||||
if (s != NULL) ret.len = strlen(s);
|
||||
return ret;
|
||||
}
|
||||
#ifdef MG_MODULE_LINES
|
||||
|
12
mongoose.h
12
mongoose.h
@ -1014,9 +1014,6 @@ struct mg_str {
|
||||
size_t len; /* Memory chunk length */
|
||||
};
|
||||
|
||||
#define MG_STR(str_literal) \
|
||||
{ str_literal, sizeof(str_literal) - 1 }
|
||||
|
||||
/*
|
||||
* Callback function (event handler) prototype, must be defined by user.
|
||||
* Mongoose calls event handler, passing events defined below.
|
||||
@ -1799,9 +1796,16 @@ int mg_match_prefix(const char *pattern, int pattern_len, const char *str);
|
||||
int mg_match_prefix_n(const char *pattern, int pattern_len, const char *str,
|
||||
int str_len);
|
||||
|
||||
/* A helper function for creating mg_str struct from plain C string */
|
||||
/*
|
||||
* A helper function for creating mg_str struct from plain C string.
|
||||
* NULL is allowed and becomes {NULL, 0}.
|
||||
*/
|
||||
struct mg_str mg_mk_str(const char *s);
|
||||
|
||||
/* Macro for initializing mg_str. */
|
||||
#define MG_MK_STR(str_literal) \
|
||||
{ str_literal, sizeof(str_literal) - 1 }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
Loading…
x
Reference in New Issue
Block a user