mirror of
https://github.com/cesanta/mongoose.git
synced 2024-11-30 23:49:01 +08:00
Make source g++ friendly
This commit is contained in:
parent
cb601b7718
commit
d7cba57e17
2
main.c
2
main.c
@ -126,7 +126,7 @@ static void verify_document_root(const char *root) {
|
|||||||
|
|
||||||
static char *sdup(const char *str) {
|
static char *sdup(const char *str) {
|
||||||
char *p;
|
char *p;
|
||||||
if ((p = malloc(strlen(str) + 1)) != NULL) {
|
if ((p = (char *) malloc(strlen(str) + 1)) != NULL) {
|
||||||
strcpy(p, str);
|
strcpy(p, str);
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
|
13
mongoose.c
13
mongoose.c
@ -23,6 +23,7 @@
|
|||||||
#else
|
#else
|
||||||
#define _XOPEN_SOURCE 600 // For flockfile() on Linux
|
#define _XOPEN_SOURCE 600 // For flockfile() on Linux
|
||||||
#define _LARGEFILE_SOURCE // Enable 64-bit file offsets
|
#define _LARGEFILE_SOURCE // Enable 64-bit file offsets
|
||||||
|
#define __STDC_FORMAT_MACROS // <inttypes.h> wants this for C++
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__SYMBIAN32__)
|
#if defined(__SYMBIAN32__)
|
||||||
@ -743,7 +744,7 @@ static const char *next_option(const char *list, struct vec *val,
|
|||||||
* so that val points to "x", and eq_val points to "y".
|
* so that val points to "x", and eq_val points to "y".
|
||||||
*/
|
*/
|
||||||
eq_val->len = 0;
|
eq_val->len = 0;
|
||||||
eq_val->ptr = memchr(val->ptr, '=', val->len);
|
eq_val->ptr = (const char *) memchr(val->ptr, '=', val->len);
|
||||||
if (eq_val->ptr != NULL) {
|
if (eq_val->ptr != NULL) {
|
||||||
eq_val->ptr++; /* Skip over '=' character */
|
eq_val->ptr++; /* Skip over '=' character */
|
||||||
eq_val->len = val->ptr + val->len - eq_val->ptr;
|
eq_val->len = val->ptr + val->len - eq_val->ptr;
|
||||||
@ -1602,7 +1603,8 @@ static struct mg_connection *mg_connect(struct mg_connection *conn,
|
|||||||
cry(conn, "%s: connect(%s:%d): %s", __func__, host, port,
|
cry(conn, "%s: connect(%s:%d): %s", __func__, host, port,
|
||||||
strerror(ERRNO));
|
strerror(ERRNO));
|
||||||
closesocket(sock);
|
closesocket(sock);
|
||||||
} else if ((newconn = calloc(1, sizeof(*newconn))) == NULL) {
|
} else if ((newconn = (struct mg_connection *)
|
||||||
|
calloc(1, sizeof(*newconn))) == NULL) {
|
||||||
cry(conn, "%s: calloc: %s", __func__, strerror(ERRNO));
|
cry(conn, "%s: calloc: %s", __func__, strerror(ERRNO));
|
||||||
closesocket(sock);
|
closesocket(sock);
|
||||||
} else {
|
} else {
|
||||||
@ -3357,7 +3359,8 @@ static int set_ports_option(struct mg_context *ctx) {
|
|||||||
cry(fc(ctx), "%s: cannot bind to %.*s: %s", __func__,
|
cry(fc(ctx), "%s: cannot bind to %.*s: %s", __func__,
|
||||||
vec.len, vec.ptr, strerror(ERRNO));
|
vec.len, vec.ptr, strerror(ERRNO));
|
||||||
success = 0;
|
success = 0;
|
||||||
} else if ((listener = calloc(1, sizeof(*listener))) == NULL) {
|
} else if ((listener = (struct socket *)
|
||||||
|
calloc(1, sizeof(*listener))) == NULL) {
|
||||||
closesocket(sock);
|
closesocket(sock);
|
||||||
cry(fc(ctx), "%s: %s", __func__, strerror(ERRNO));
|
cry(fc(ctx), "%s: %s", __func__, strerror(ERRNO));
|
||||||
success = 0;
|
success = 0;
|
||||||
@ -3872,7 +3875,7 @@ static void worker_thread(struct mg_context *ctx) {
|
|||||||
struct mg_connection *conn;
|
struct mg_connection *conn;
|
||||||
int buf_size = atoi(ctx->config[MAX_REQUEST_SIZE]);
|
int buf_size = atoi(ctx->config[MAX_REQUEST_SIZE]);
|
||||||
|
|
||||||
conn = calloc(1, sizeof(*conn) + buf_size);
|
conn = (struct mg_connection *) calloc(1, sizeof(*conn) + buf_size);
|
||||||
conn->buf_size = buf_size;
|
conn->buf_size = buf_size;
|
||||||
conn->buf = (char *) (conn + 1);
|
conn->buf = (char *) (conn + 1);
|
||||||
assert(conn != NULL);
|
assert(conn != NULL);
|
||||||
@ -4062,7 +4065,7 @@ struct mg_context *mg_start(mg_callback_t user_callback, void *user_data,
|
|||||||
|
|
||||||
// Allocate context and initialize reasonable general case defaults.
|
// Allocate context and initialize reasonable general case defaults.
|
||||||
// TODO(lsm): do proper error handling here.
|
// TODO(lsm): do proper error handling here.
|
||||||
ctx = calloc(1, sizeof(*ctx));
|
ctx = (struct mg_context *) calloc(1, sizeof(*ctx));
|
||||||
ctx->user_callback = user_callback;
|
ctx->user_callback = user_callback;
|
||||||
ctx->user_data = user_data;
|
ctx->user_data = user_data;
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ enum mg_event {
|
|||||||
MG_NEW_REQUEST, // New HTTP request has arrived from the client
|
MG_NEW_REQUEST, // New HTTP request has arrived from the client
|
||||||
MG_HTTP_ERROR, // HTTP error must be returned to the client
|
MG_HTTP_ERROR, // HTTP error must be returned to the client
|
||||||
MG_EVENT_LOG, // Mongoose logs an event, request_info.log_message
|
MG_EVENT_LOG, // Mongoose logs an event, request_info.log_message
|
||||||
MG_INIT_SSL, // Mongoose initializes SSL. Instead of mg_connection *,
|
MG_INIT_SSL // Mongoose initializes SSL. Instead of mg_connection *,
|
||||||
// SSL context is passed to the callback function.
|
// SSL context is passed to the callback function.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user