summaryrefslogtreecommitdiff
path: root/src/http_decoder_utils.h
diff options
context:
space:
mode:
authorlijia <[email protected]>2024-04-08 09:48:13 +0800
committerlijia <[email protected]>2024-04-08 09:48:13 +0800
commit215e383be1f47cd18c235855d0cee0485f6cb423 (patch)
tree34668fd59622c37826c3a786ba0e196a7d65147b /src/http_decoder_utils.h
parentea795e9c6940281bf8557bfd79f13f319f947c58 (diff)
Separate from stellar-on-sapp project.
Diffstat (limited to 'src/http_decoder_utils.h')
-rw-r--r--src/http_decoder_utils.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/http_decoder_utils.h b/src/http_decoder_utils.h
new file mode 100644
index 0000000..9c031a3
--- /dev/null
+++ b/src/http_decoder_utils.h
@@ -0,0 +1,66 @@
+/*
+**********************************************************************************************
+* File: http_decoder_utils.h
+* Description:
+* Authors: LuWenPeng <[email protected]>
+* Date: 2022-10-31
+* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved.
+***********************************************************************************************
+*/
+
+
+#ifndef _HTTP_DECODER_UTILS_H_
+#define _HTTP_DECODER_UTILS_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+
+
+char *safe_dup(const char *str, size_t len);
+
+/******************************************************************************
+ * Logger
+ ******************************************************************************/
+
+enum http_decoder_log_level {
+ DEBUG = 0x11,
+ WARN = 0x12,
+ INFO = 0x13,
+ ERROR = 0x14,
+};
+
+#ifndef http_decoder_log
+#define http_decoder_log(level, format, ...) \
+ { \
+ switch (level) \
+ { \
+ case DEBUG: \
+ fprintf(stdout, "HTTP_DECODER [DEBUG] " format "\n", ##__VA_ARGS__); \
+ fflush(stdout); \
+ break; \
+ case WARN: \
+ fprintf(stdout, "HTTP_DECODER [WARN] " format "\n", ##__VA_ARGS__); \
+ fflush(stdout); \
+ break; \
+ case INFO: \
+ fprintf(stdout, "HTTP_DECODER [INFO] " format "\n", ##__VA_ARGS__); \
+ fflush(stdout); \
+ break; \
+ case ERROR: \
+ fprintf(stderr, "HTTP_DECODER [ERROR] " format "\n", ##__VA_ARGS__); \
+ fflush(stderr); \
+ break; \
+ } \
+ }
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif \ No newline at end of file