summaryrefslogtreecommitdiff
path: root/src/http_decoder_string.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_string.h
parentea795e9c6940281bf8557bfd79f13f319f947c58 (diff)
Separate from stellar-on-sapp project.
Diffstat (limited to 'src/http_decoder_string.h')
-rw-r--r--src/http_decoder_string.h95
1 files changed, 95 insertions, 0 deletions
diff --git a/src/http_decoder_string.h b/src/http_decoder_string.h
new file mode 100644
index 0000000..f9d81dd
--- /dev/null
+++ b/src/http_decoder_string.h
@@ -0,0 +1,95 @@
+/*
+**********************************************************************************************
+* File: http_decoder_string.h
+* Description:
+* Authors: LuWenPeng <[email protected]>
+* Date: 2022-10-31
+* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved.
+***********************************************************************************************
+*/
+
+#ifndef _HTTP_DECODER_STRING_H_
+#define _HTTP_DECODER_STRING_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include "http_decoder.h"
+
+
+enum string_state {
+ STRING_STATE_INIT,
+ STRING_STATE_REFER,
+ STRING_STATE_CACHE,
+ STRING_STATE_COMMIT,
+};
+
+/* state transition diagram
+ * +----------+
+ * | |
+ * \|/ |
+ * +------+ |
+ * | init | |
+ * +------+ |
+ * | |
+ * +---->| |
+ * | \|/ |
+ * | +-------+ |
+ * | | refer |--+ |
+ * | +-------+ | |
+ * | | | |
+ * | \|/ | |
+ * | +-------+ | |
+ * +--| cache | | |
+ * +-------+ | |
+ * | | |
+ * |<------+ |
+ * \|/ |
+ * +--------+ |
+ * | commit | |
+ * +--------+ |
+ * | |
+ * \|/ |
+ * +--------+ |
+ * | reset |----+
+ * +--------+
+ */
+
+
+//http decoder string
+struct http_decoder_string {
+ struct hstring refer; // shallow copy
+ struct hstring cache; // deep copy
+ struct hstring commit;
+
+ enum string_state state;
+ size_t max_cache_size;
+};
+
+void http_decoder_string_refer(struct http_decoder_string *rstr,
+ const char *at, size_t length);
+
+void http_decoder_string_cache(struct http_decoder_string *rstr);
+
+void http_decoder_string_commit(struct http_decoder_string *rstr);
+
+void http_decoder_string_reset(struct http_decoder_string *rstr);
+
+void http_decoder_string_init(struct http_decoder_string *rstr,
+ size_t max_cache_size);
+
+void http_decoder_string_reinit(struct http_decoder_string *rstr);
+
+enum string_state http_decoder_string_state(struct http_decoder_string *rstr);
+
+int http_decoder_string_get(struct http_decoder_string *rstr, struct hstring *out);
+
+void http_decoder_string_dump(struct http_decoder_string *rstr, const char *desc);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif \ No newline at end of file