diff mbox series

[06/23] mongoose: Forward port deprecated mg_strstr()

Message ID 20240612144010.470339-7-Michael.Glembotzki@iris-sensing.com
State Changes Requested
Headers show
Series Update Mongoose Version to 7.14 | expand

Commit Message

Michael Glembotzki June 12, 2024, 2:36 p.m. UTC
mongoose rev-id: b46bee0540c83c780ae9622ef18b9cc8a7b3ebab

Signed-off-by: Michael Glembotzki <Michael.Glembotzki@iris-sensing.com>
---
 mongoose/mongoose_multipart.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/mongoose/mongoose_multipart.c b/mongoose/mongoose_multipart.c
index fccc5a62..5e57d326 100644
--- a/mongoose/mongoose_multipart.c
+++ b/mongoose/mongoose_multipart.c
@@ -48,6 +48,19 @@  static void mg_http_free_proto_data_mp_stream(
 	memset(mp, 0, sizeof(*mp));
 }
 
+static const char *mg_strstr(const struct mg_str haystack,
+                      const struct mg_str needle) {
+  size_t i;
+  if (needle.len > haystack.len) return NULL;
+  if (needle.len == 0) return haystack.buf;
+  for (i = 0; i <= haystack.len - needle.len; i++) {
+    if (memcmp(haystack.buf + i, needle.buf, needle.len) == 0) {
+      return haystack.buf + i;
+    }
+  }
+  return NULL;
+}
+
 static void mg_http_multipart_begin(struct mg_connection *c,
 									struct mg_http_message *hm) {
 	struct mg_http_multipart_stream *mp_stream;