mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-26 22:41:03 +08:00
Add printf.h
This commit is contained in:
parent
2b325102f3
commit
8e14ad0536
2
Makefile
2
Makefile
@ -194,7 +194,7 @@ mongoose.c: Makefile $(wildcard src/*.c) $(wildcard src/tcpip/*.c)
|
||||
(cat src/license.h; echo; echo '#include "mongoose.h"' ; (for F in src/*.c src/tcpip/*.c ; do echo; echo '#ifdef MG_ENABLE_LINES'; echo "#line 1 \"$$F\""; echo '#endif'; cat $$F | sed -e 's,#include ".*,,'; done))> $@
|
||||
|
||||
mongoose.h: $(HDRS) Makefile
|
||||
(cat src/license.h; echo; echo '#ifndef MONGOOSE_H'; echo '#define MONGOOSE_H'; echo; cat src/version.h ; echo; echo '#ifdef __cplusplus'; echo 'extern "C" {'; echo '#endif'; cat src/arch.h src/arch_*.h src/net_*.h src/config.h src/str.h src/queue.h src/fmt.h src/log.h src/timer.h src/fs.h src/util.h src/url.h src/iobuf.h src/base64.h src/md5.h src/sha1.h src/event.h src/net.h src/http.h src/ssi.h src/tls.h src/tls_mbed.h src/tls_openssl.h src/ws.h src/sntp.h src/mqtt.h src/dns.h src/json.h src/rpc.h src/tcpip/tcpip.h src/tcpip/driver_*.h | sed -e '/keep/! s,#include ".*,,' -e 's,^#pragma once,,'; echo; echo '#ifdef __cplusplus'; echo '}'; echo '#endif'; echo '#endif // MONGOOSE_H')> $@
|
||||
(cat src/license.h; echo; echo '#ifndef MONGOOSE_H'; echo '#define MONGOOSE_H'; echo; cat src/version.h ; echo; echo '#ifdef __cplusplus'; echo 'extern "C" {'; echo '#endif'; cat src/arch.h src/arch_*.h src/net_*.h src/config.h src/str.h src/queue.h src/fmt.h src/printf.h src/log.h src/timer.h src/fs.h src/util.h src/url.h src/iobuf.h src/base64.h src/md5.h src/sha1.h src/event.h src/net.h src/http.h src/ssi.h src/tls.h src/tls_mbed.h src/tls_openssl.h src/ws.h src/sntp.h src/mqtt.h src/dns.h src/json.h src/rpc.h src/tcpip/tcpip.h src/tcpip/driver_*.h | sed -e '/keep/! s,#include ".*,,' -e 's,^#pragma once,,'; echo; echo '#ifdef __cplusplus'; echo '}'; echo '#endif'; echo '#endif // MONGOOSE_H')> $@
|
||||
|
||||
|
||||
clean: clean_examples clean_embedded
|
||||
|
@ -117,6 +117,7 @@ int mg_base64_decode(const char *src, int n, char *dst) {
|
||||
|
||||
|
||||
|
||||
|
||||
struct dns_data {
|
||||
struct dns_data *next;
|
||||
struct mg_connection *c;
|
||||
@ -1305,6 +1306,7 @@ struct mg_fs mg_fs_posix = {p_stat, p_list, p_open, p_close, p_read,
|
||||
|
||||
|
||||
|
||||
|
||||
// Chunk deletion marker is the MSB in the "processed" counter
|
||||
#define MG_DMARK ((size_t) 1 << (sizeof(size_t) * 8 - 1))
|
||||
|
||||
@ -3243,6 +3245,7 @@ struct mg_connection *mg_mqtt_listen(struct mg_mgr *mgr, const char *url,
|
||||
|
||||
|
||||
|
||||
|
||||
size_t mg_vprintf(struct mg_connection *c, const char *fmt, va_list *ap) {
|
||||
size_t old = c->send.len;
|
||||
mg_vxprintf(mg_pfn_iobuf, &c->send, fmt, ap);
|
||||
@ -3491,7 +3494,6 @@ void mg_mgr_init(struct mg_mgr *mgr) {
|
||||
|
||||
|
||||
|
||||
|
||||
size_t mg_queue_vprintf(struct mg_queue *q, const char *fmt, va_list *ap) {
|
||||
size_t len = mg_snprintf(NULL, 0, fmt, ap);
|
||||
char *buf;
|
||||
@ -4103,6 +4105,7 @@ struct mg_connection *mg_sntp_connect(struct mg_mgr *mgr, const char *url,
|
||||
|
||||
|
||||
|
||||
|
||||
#if MG_ENABLE_SOCKET
|
||||
|
||||
#ifndef closesocket
|
||||
@ -5775,6 +5778,7 @@ uint64_t mg_millis(void) {
|
||||
|
||||
|
||||
|
||||
|
||||
struct ws_msg {
|
||||
uint8_t flags;
|
||||
size_t header_len;
|
||||
|
@ -862,14 +862,17 @@ void mg_queue_del(struct mg_queue *, size_t); // Delete oldest message
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef void (*mg_pfn_t)(char, void *); // Output function
|
||||
typedef size_t (*mg_pm_t)(mg_pfn_t, void *, va_list *); // %M printer
|
||||
|
||||
size_t mg_vxprintf(void (*)(char, void *), void *, const char *fmt, va_list *);
|
||||
size_t mg_xprintf(void (*fn)(char, void *), void *, const char *fmt, ...);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Convenience wrappers around mg_xprintf
|
||||
size_t mg_vsnprintf(char *buf, size_t len, const char *fmt, va_list *ap);
|
||||
size_t mg_snprintf(char *, size_t, const char *fmt, ...);
|
||||
@ -989,7 +992,6 @@ bool mg_file_printf(struct mg_fs *fs, const char *path, const char *fmt, ...);
|
||||
|
||||
|
||||
|
||||
|
||||
#if MG_ENABLE_ASSERT
|
||||
#include <assert.h>
|
||||
#elif !defined(assert)
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "dns.h"
|
||||
#include "log.h"
|
||||
#include "printf.h"
|
||||
#include "str.h"
|
||||
#include "timer.h"
|
||||
#include "url.h"
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "event.h"
|
||||
#include "fmt.h"
|
||||
#include "log.h"
|
||||
#include "net.h"
|
||||
#include "printf.h"
|
||||
|
||||
void mg_call(struct mg_connection *c, int ev, void *ev_data) {
|
||||
// Run user-defined handler first, in order to give it an ability
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "fmt.h"
|
||||
#include "iobuf.h"
|
||||
#include "printf.h"
|
||||
#include "util.h"
|
||||
|
||||
static bool is_digit(int c) { return c >= '0' && c <= '9'; }
|
||||
|
21
src/fmt.h
21
src/fmt.h
@ -1,30 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "arch.h"
|
||||
#include "iobuf.h"
|
||||
#include "queue.h"
|
||||
|
||||
typedef void (*mg_pfn_t)(char, void *); // Output function
|
||||
typedef size_t (*mg_pm_t)(mg_pfn_t, void *, va_list *); // %M printer
|
||||
|
||||
size_t mg_vxprintf(void (*)(char, void *), void *, const char *fmt, va_list *);
|
||||
size_t mg_xprintf(void (*fn)(char, void *), void *, const char *fmt, ...);
|
||||
|
||||
// Convenience wrappers around mg_xprintf
|
||||
size_t mg_vsnprintf(char *buf, size_t len, const char *fmt, va_list *ap);
|
||||
size_t mg_snprintf(char *, size_t, const char *fmt, ...);
|
||||
char *mg_vmprintf(const char *fmt, va_list *ap);
|
||||
char *mg_mprintf(const char *fmt, ...);
|
||||
size_t mg_queue_vprintf(struct mg_queue *, const char *fmt, va_list *);
|
||||
size_t mg_queue_printf(struct mg_queue *, const char *fmt, ...);
|
||||
|
||||
// %M print helper functions
|
||||
size_t mg_print_ip(void (*out)(char, void *), void *arg, va_list *ap);
|
||||
size_t mg_print_ip_port(void (*out)(char, void *), void *arg, va_list *ap);
|
||||
size_t mg_print_ip4(void (*out)(char, void *), void *arg, va_list *ap);
|
||||
size_t mg_print_ip6(void (*out)(char, void *), void *arg, va_list *ap);
|
||||
size_t mg_print_mac(void (*out)(char, void *), void *arg, va_list *ap);
|
||||
|
||||
// Various output functions
|
||||
void mg_pfn_iobuf(char ch, void *param); // param: struct mg_iobuf *
|
||||
void mg_pfn_stdout(char c, void *param); // param: ignored
|
||||
|
2
src/fs.c
2
src/fs.c
@ -1,5 +1,5 @@
|
||||
#include "fs.h"
|
||||
#include "fmt.h"
|
||||
#include "printf.h"
|
||||
|
||||
struct mg_fd *mg_fs_open(struct mg_fs *fs, const char *path, int flags) {
|
||||
struct mg_fd *fd = (struct mg_fd *) calloc(1, sizeof(*fd));
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "fmt.h"
|
||||
#include "fs.h"
|
||||
#include "printf.h"
|
||||
#include "str.h"
|
||||
|
||||
struct packed_file {
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "json.h"
|
||||
#include "log.h"
|
||||
#include "net.h"
|
||||
#include "printf.h"
|
||||
#include "ssi.h"
|
||||
#include "util.h"
|
||||
#include "version.h"
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "fmt.h"
|
||||
#include "log.h"
|
||||
#include "net.h"
|
||||
#include "printf.h"
|
||||
#include "timer.h"
|
||||
#include "tls.h"
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "fmt.h"
|
||||
#include "iobuf.h"
|
||||
#include "queue.h"
|
||||
#include "printf.h"
|
||||
#include "util.h"
|
||||
|
||||
size_t mg_queue_vprintf(struct mg_queue *q, const char *fmt, va_list *ap) {
|
||||
|
24
src/printf.h
Normal file
24
src/printf.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "arch.h"
|
||||
#include "iobuf.h"
|
||||
#include "queue.h"
|
||||
|
||||
// Convenience wrappers around mg_xprintf
|
||||
size_t mg_vsnprintf(char *buf, size_t len, const char *fmt, va_list *ap);
|
||||
size_t mg_snprintf(char *, size_t, const char *fmt, ...);
|
||||
char *mg_vmprintf(const char *fmt, va_list *ap);
|
||||
char *mg_mprintf(const char *fmt, ...);
|
||||
size_t mg_queue_vprintf(struct mg_queue *, const char *fmt, va_list *);
|
||||
size_t mg_queue_printf(struct mg_queue *, const char *fmt, ...);
|
||||
|
||||
// %M print helper functions
|
||||
size_t mg_print_ip(void (*out)(char, void *), void *arg, va_list *ap);
|
||||
size_t mg_print_ip_port(void (*out)(char, void *), void *arg, va_list *ap);
|
||||
size_t mg_print_ip4(void (*out)(char, void *), void *arg, va_list *ap);
|
||||
size_t mg_print_ip6(void (*out)(char, void *), void *arg, va_list *ap);
|
||||
size_t mg_print_mac(void (*out)(char, void *), void *arg, va_list *ap);
|
||||
|
||||
// Various output functions
|
||||
void mg_pfn_iobuf(char ch, void *param); // param: struct mg_iobuf *
|
||||
void mg_pfn_stdout(char c, void *param); // param: ignored
|
@ -2,6 +2,7 @@
|
||||
#include "event.h"
|
||||
#include "log.h"
|
||||
#include "net.h"
|
||||
#include "printf.h"
|
||||
#include "str.h"
|
||||
#include "timer.h"
|
||||
#include "tls.h"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "ssi.h"
|
||||
#include "fmt.h"
|
||||
#include "log.h"
|
||||
#include "printf.h"
|
||||
#include "ssi.h"
|
||||
|
||||
#ifndef MG_MAX_SSI_DEPTH
|
||||
#define MG_MAX_SSI_DEPTH 5
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "fmt.h"
|
||||
#include "fs.h"
|
||||
#include "printf.h"
|
||||
#include "tls.h"
|
||||
|
||||
#if MG_ENABLE_MBEDTLS
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "fmt.h"
|
||||
#include "printf.h"
|
||||
#include "tls.h"
|
||||
|
||||
#if MG_ENABLE_OPENSSL
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include "arch.h"
|
||||
#include "config.h"
|
||||
#include "fmt.h"
|
||||
#include "net.h"
|
||||
#include "str.h"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user