diff mbox series

[12/23] mongoose: Replace deprecated struct mg_str::ptr with struct mg_str::buf

Message ID 20240612144010.470339-13-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
.. and fix removed constness.

mongoose rev-id: b46bee0540c83c780ae9622ef18b9cc8a7b3ebab

Signed-off-by: Michael Glembotzki <Michael.Glembotzki@iris-sensing.com>
---
 mongoose/mongoose_interface.c | 16 ++++++++--------
 mongoose/mongoose_multipart.c | 16 ++++++++--------
 2 files changed, 16 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c
index 463dd073..019eae6c 100644
--- a/mongoose/mongoose_interface.c
+++ b/mongoose/mongoose_interface.c
@@ -190,9 +190,9 @@  static void mg_mkmd5resp(struct mg_str method, struct mg_str uri, struct mg_str
 	static const char colon[] = ":";
 	static const size_t one = 1;
 	char ha2[33];
-	cs_md5(ha2, method.ptr, method.len, colon, one, uri.ptr, uri.len, NULL);
-	cs_md5(resp, ha1.ptr, ha1.len, colon, one, nonce.ptr, nonce.len, colon, one, nc.ptr,
-		   nc.len, colon, one, cnonce.ptr, cnonce.len, colon, one, qop.ptr, qop.len,
+	cs_md5(ha2, method.buf, method.len, colon, one, uri.buf, uri.len, NULL);
+	cs_md5(resp, ha1.buf, ha1.len, colon, one, nonce.buf, nonce.len, colon, one, nc.buf,
+		   nc.len, colon, one, cnonce.buf, cnonce.len, colon, one, qop.buf, qop.len,
 		   colon, one, ha2, sizeof(ha2) - 1, NULL);
 }
 
@@ -216,7 +216,7 @@  static double mg_time(void)
 static int mg_check_nonce(struct mg_str nonce)
 {
 	unsigned long now = (unsigned long) mg_time();
-	unsigned long val = (unsigned long) strtoul(nonce.ptr, NULL, 16);
+	unsigned long val = (unsigned long) strtoul(nonce.buf, NULL, 16);
 	return (now >= val) && (now - val < 60 * 60);
 }
 
@@ -240,7 +240,7 @@  static int mg_check_digest_auth(struct mg_str method, struct mg_str uri,
 			mg_vcmp(&auth_domain, f_domain) == 0) {
 			/* Username and domain matched, check the password */
 			mg_mkmd5resp(method, uri, mg_str_s(f_ha1), nonce, nc, cnonce, qop, exp_resp);
-			return mg_ncasecmp(response.ptr, exp_resp, strlen(exp_resp)) == 0;
+			return mg_ncasecmp(response.buf, exp_resp, strlen(exp_resp)) == 0;
 		}
 	}
 
@@ -272,7 +272,7 @@  static int mg_http_check_digest_auth(struct mg_http_message *hm, struct mg_str a
 	return mg_check_digest_auth(
 			hm->method,
 			mg_str_n(
-					hm->uri.ptr,
+					hm->uri.buf,
 					hm->uri.len + (hm->query.len ? hm->query.len + 1 : 0)),
 			username, cnonce, response, qop, nc, nonce, auth_domain, fp);
 }
@@ -589,7 +589,7 @@  static void upload_handler(struct mg_connection *nc, int ev, void *ev_data)
 			struct swupdate_request req;
 			swupdate_prepare_req(&req);
 			req.len = mp->len;
-			strncpy(req.info, mp->part.filename.ptr, sizeof(req.info) - 1);
+			strncpy(req.info, mp->part.filename.buf, sizeof(req.info) - 1);
 			req.source = SOURCE_WEBSERVER;
 			fus->fd = ipc_inst_start_ext(&req, sizeof(req));
 			if (fus->fd < 0) {
@@ -624,7 +624,7 @@  static void upload_handler(struct mg_connection *nc, int ev, void *ev_data)
 			if (!fus)
 				break;
 
-			written = write(fus->fd, (char *) mp->part.body.ptr, mp->part.body.len);
+			written = write(fus->fd, (char *) mp->part.body.buf, mp->part.body.len);
 			/*
 			 * IPC seems to block, wait for a while
 			 */
diff --git a/mongoose/mongoose_multipart.c b/mongoose/mongoose_multipart.c
index 29ec8a0b..6db59aff 100644
--- a/mongoose/mongoose_multipart.c
+++ b/mongoose/mongoose_multipart.c
@@ -42,9 +42,9 @@  struct mg_http_multipart_stream {
 
 static void mg_http_free_proto_data_mp_stream(
 		struct mg_http_multipart_stream *mp) {
-	free((void *) mp->boundary.ptr);
-	free((void *) mp->part.name.ptr);
-	free((void *) mp->part.filename.ptr);
+	free((void *) mp->boundary.buf);
+	free((void *) mp->part.name.buf);
+	free((void *) mp->part.filename.buf);
 	memset(mp, 0, sizeof(*mp));
 }
 
@@ -76,7 +76,7 @@  static void mg_http_multipart_begin(struct mg_connection *c,
 	}
 
 	/* Content-type should start with "multipart" */
-	if (ct->len < 9 || strncmp(ct->ptr, "multipart", 9) != 0) {
+	if (ct->len < 9 || strncmp(ct->buf, "multipart", 9) != 0) {
 		return;
 	}
 
@@ -108,7 +108,7 @@  static void mg_http_multipart_begin(struct mg_connection *c,
 		}
 		mp_stream->state = MPS_BEGIN;
 		mp_stream->boundary = mg_strdup(boundary);
-		mp_stream->part.name.ptr = mp_stream->part.filename.ptr = NULL;
+		mp_stream->part.name.buf = mp_stream->part.filename.buf = NULL;
 		mp_stream->part.name.len = mp_stream->part.filename.len = 0;
 		mp_stream->len = hm->body.len;
 		c->pfn_data = mp_stream;
@@ -128,7 +128,7 @@  static size_t mg_http_multipart_call_handler(struct mg_connection *c, int ev,
 	mp.part.name = mp_stream->part.name;
 	mp.part.filename = mp_stream->part.filename;
 	mp.user_data = mp_stream->user_data;
-	mp.part.body.ptr = data;
+	mp.part.body.buf = (char*) data;
 	mp.part.body.len = data_len;
 	mp.num_data_consumed = data_len;
 	mp.len = mp_stream->len;
@@ -207,7 +207,7 @@  static int mg_http_multipart_process_boundary(struct mg_connection *c) {
 						sizeof(CONTENT_DISPOSITION) - 1) == 0) {
 			struct mg_str header;
 
-			header.ptr = block_begin + sizeof(CONTENT_DISPOSITION) - 1;
+			header.buf = (char*) (block_begin + sizeof(CONTENT_DISPOSITION) - 1);
 			header.len = line_len - sizeof(CONTENT_DISPOSITION) - 1;
 
 			mp_stream->part.name = mg_strdup(mg_http_get_header_var(header, mg_str_n("name", 4)));
@@ -342,7 +342,7 @@  void multipart_upload_handler(struct mg_connection *c, int ev, void *ev_data)
 			return;
 		}
 		s = mg_http_get_header(hm, "Content-Type");
-		if (s != NULL && s->len >= 9 && strncmp(s->ptr, "multipart", 9) == 0) {
+		if (s != NULL && s->len >= 9 && strncmp(s->buf, "multipart", 9) == 0) {
 			/* New request - new proto data */
 			c->data[0] = 'M';