mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-24 20:21:49 +00:00
Added declarations for printf like functions
This commit is contained in:
1 parent
d2be594262
commit
ed74cd82f5
1 file changed
+12
-5
+12
-5
@@ -564,6 +564,9 @@ static void sockaddr_to_string(char *buf, size_t len,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cry(struct mg_connection *conn,
|
||||||
|
PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(2, 3);
|
||||||
|
|
||||||
// Print error message to the opened error log stream.
|
// Print error message to the opened error log stream.
|
||||||
static void cry(struct mg_connection *conn, const char *fmt, ...) {
|
static void cry(struct mg_connection *conn, const char *fmt, ...) {
|
||||||
char buf[MG_BUF_LEN], src_addr[20];
|
char buf[MG_BUF_LEN], src_addr[20];
|
||||||
@@ -696,6 +699,10 @@ static int mg_vsnprintf(struct mg_connection *conn, char *buf, size_t buflen,
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int mg_snprintf(struct mg_connection *conn, char *buf, size_t buflen,
|
||||||
|
PRINTF_FORMAT_STRING(const char *fmt), ...)
|
||||||
|
PRINTF_ARGS(4, 5);
|
||||||
|
|
||||||
static int mg_snprintf(struct mg_connection *conn, char *buf, size_t buflen,
|
static int mg_snprintf(struct mg_connection *conn, char *buf, size_t buflen,
|
||||||
const char *fmt, ...) {
|
const char *fmt, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -887,7 +894,6 @@ static void send_http_error(struct mg_connection *conn, int status,
|
|||||||
int len;
|
int len;
|
||||||
|
|
||||||
conn->status_code = status;
|
conn->status_code = status;
|
||||||
|
|
||||||
if (call_user(conn, MG_HTTP_ERROR) == NULL) {
|
if (call_user(conn, MG_HTTP_ERROR) == NULL) {
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
len = 0;
|
len = 0;
|
||||||
@@ -1672,7 +1678,8 @@ static int convert_uri_to_file_name(struct mg_connection *conn, char *buf,
|
|||||||
rewrite = conn->ctx->config[REWRITE];
|
rewrite = conn->ctx->config[REWRITE];
|
||||||
while ((rewrite = next_option(rewrite, &a, &b)) != NULL) {
|
while ((rewrite = next_option(rewrite, &a, &b)) != NULL) {
|
||||||
if ((match_len = match_prefix(a.ptr, a.len, uri)) > 0) {
|
if ((match_len = match_prefix(a.ptr, a.len, uri)) > 0) {
|
||||||
mg_snprintf(conn, buf, buf_len, "%.*s%s", b.len, b.ptr, uri + match_len);
|
mg_snprintf(conn, buf, buf_len, "%.*s%s", (int) b.len, b.ptr,
|
||||||
|
uri + match_len);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2283,8 +2290,8 @@ static int check_authorization(struct mg_connection *conn, const char *path) {
|
|||||||
list = conn->ctx->config[PROTECT_URI];
|
list = conn->ctx->config[PROTECT_URI];
|
||||||
while ((list = next_option(list, &uri_vec, &filename_vec)) != NULL) {
|
while ((list = next_option(list, &uri_vec, &filename_vec)) != NULL) {
|
||||||
if (!memcmp(conn->request_info.uri, uri_vec.ptr, uri_vec.len)) {
|
if (!memcmp(conn->request_info.uri, uri_vec.ptr, uri_vec.len)) {
|
||||||
(void) mg_snprintf(conn, fname, sizeof(fname), "%.*s",
|
mg_snprintf(conn, fname, sizeof(fname), "%.*s",
|
||||||
filename_vec.len, filename_vec.ptr);
|
(int) filename_vec.len, filename_vec.ptr);
|
||||||
if ((fp = mg_fopen(fname, "r")) == NULL) {
|
if ((fp = mg_fopen(fname, "r")) == NULL) {
|
||||||
cry(conn, "%s: cannot open %s: %s", __func__, fname, strerror(errno));
|
cry(conn, "%s: cannot open %s: %s", __func__, fname, strerror(errno));
|
||||||
}
|
}
|
||||||
@@ -3898,7 +3905,7 @@ static int set_ports_option(struct mg_context *ctx) {
|
|||||||
listen(sock, SOMAXCONN) != 0) {
|
listen(sock, SOMAXCONN) != 0) {
|
||||||
closesocket(sock);
|
closesocket(sock);
|
||||||
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));
|
(int) vec.len, vec.ptr, strerror(ERRNO));
|
||||||
success = 0;
|
success = 0;
|
||||||
} else if ((listener = (struct socket *)
|
} else if ((listener = (struct socket *)
|
||||||
calloc(1, sizeof(*listener))) == NULL) {
|
calloc(1, sizeof(*listener))) == NULL) {
|
||||||
|
|||||||
Reference in new issue
Block a user