Skip to content

Commit e0e599f

Browse files
committed
Fix #2612 - struct mg_str::ptr -> buf
1 parent e93d18d commit e0e599f

File tree

61 files changed

+684
-686
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+684
-686
lines changed

examples/arduino/teensy41-http/teensy41-http.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ static void simple_http_listener(struct mg_connection *c, int ev, void *ev_data)
3737
// Content-Length header automatically. In the response, we show
3838
// the requested URI and HTTP body:
3939
mg_http_reply(c, 200, "", "{%m:%m,%m:%m}\n", // See mg_snprintf doc
40-
MG_ESC("uri"), mg_print_esc, hm->uri.len, hm->uri.ptr,
41-
MG_ESC("body"), mg_print_esc, hm->body.len, hm->body.ptr);
40+
MG_ESC("uri"), mg_print_esc, hm->uri.len, hm->uri.buf,
41+
MG_ESC("body"), mg_print_esc, hm->body.len, hm->body.buf);
4242
} else {
4343
// For all other URIs, serve some static content
4444
mg_http_reply(c, 200, "", "<html>millis: %lu</html>", millis());

examples/arduino/w5500-mqtt/net.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
2626
// Received MQTT message
2727
struct mg_mqtt_message *mm = (struct mg_mqtt_message *) ev_data;
2828
MG_INFO(("%lu RECEIVED %.*s <- %.*s", c->id, (int) mm->data.len,
29-
mm->data.ptr, (int) mm->topic.len, mm->topic.ptr));
30-
exec_command(mm->data.ptr, mm->data.len);
29+
mm->data.buf, (int) mm->topic.len, mm->topic.buf));
30+
exec_command(mm->data.buf, mm->data.len);
3131
} else if (ev == MG_EV_CLOSE) {
3232
MG_INFO(("%lu CLOSED", c->id));
3333
mqtt_connection = NULL;

examples/device-dashboard/net.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static void handle_firmware_upload(struct mg_connection *c,
210210
mg_http_reply(c, 500, "", "offset and total not set\n");
211211
} else if (ofs == 0 && mg_ota_begin((size_t) tot) == false) {
212212
mg_http_reply(c, 500, "", "mg_ota_begin(%ld) failed\n", tot);
213-
} else if (data.len > 0 && mg_ota_write(data.ptr, data.len) == false) {
213+
} else if (data.len > 0 && mg_ota_write(data.buf, data.len) == false) {
214214
mg_http_reply(c, 500, "", "mg_ota_write(%lu) @%ld failed\n", data.len, ofs);
215215
mg_ota_end();
216216
} else if (data.len == 0 && mg_ota_end() == false) {
@@ -313,7 +313,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
313313
mg_http_serve_dir(c, ev_data, &opts);
314314
}
315315
MG_DEBUG(("%lu %.*s %.*s -> %.*s", c->id, (int) hm->method.len,
316-
hm->method.ptr, (int) hm->uri.len, hm->uri.ptr, (int) 3,
316+
hm->method.buf, (int) hm->uri.len, hm->uri.buf, (int) 3,
317317
&c->send.buf[9]));
318318
}
319319
}

examples/esp32/uart-bridge/main/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct mg_str config_read(void) {
1010
}
1111

1212
void config_write(struct mg_str config) {
13-
mg_file_write(&mg_fs_posix, FS_ROOT "/config.json", config.ptr, config.len);
13+
mg_file_write(&mg_fs_posix, FS_ROOT "/config.json", config.buf, config.len);
1414
}
1515

1616
void app_main(void) {
@@ -22,13 +22,13 @@ void app_main(void) {
2222

2323
// Try to connect to wifi by using saved WiFi credentials
2424
struct mg_str json = mg_file_read(&mg_fs_posix, WIFI_FILE);
25-
if (json.ptr != NULL) {
25+
if (json.buf != NULL) {
2626
char *ssid = mg_json_get_str(json, "$.ssid");
2727
char *pass = mg_json_get_str(json, "$.pass");
2828
while (!wifi_init(ssid, pass)) (void) 0;
2929
free(ssid);
3030
free(pass);
31-
free((void *) json.ptr);
31+
free((void *) json.buf);
3232
} else {
3333
// If WiFi is not configured, run CLI until configured
3434
MG_INFO(("WiFi is not configured, running CLI. Press enter"));

examples/esp8266/http-client-server/src/main/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ static void cb(struct mg_connection *c, int ev, void *ev_data) {
2323
static void cb2(struct mg_connection *c, int ev, void *ev_data) {
2424
if (ev == MG_EV_CONNECT) {
2525
struct mg_str s = mg_url_host(CLIENT_URL);
26-
mg_printf(c, "GET / HTTP/1.0\r\nHost: %.*s\r\n\r\n", (int) s.len, s.ptr);
26+
mg_printf(c, "GET / HTTP/1.0\r\nHost: %.*s\r\n\r\n", (int) s.len, s.buf);
2727
} else if (ev == MG_EV_HTTP_MSG) {
2828
struct mg_http_message *hm = ev_data; // Print HTTP response
29-
MG_INFO(("Fetched:\n%.*s", (int) hm->message.len, hm->message.ptr));
29+
MG_INFO(("Fetched:\n%.*s", (int) hm->message.len, hm->message.buf));
3030
c->is_draining = 1;
3131
}
3232
}

examples/file-transfer/client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
3838
"Host: %.*s\r\n"
3939
"Content-Type: octet-stream\r\n"
4040
"Content-Length: %d\r\n",
41-
mg_url_uri(s_url), (int) host.len, host.ptr, fsize);
41+
mg_url_uri(s_url), (int) host.len, host.buf, fsize);
4242
mg_http_bauth(c, s_user, s_pass); // Add Basic auth header
4343
mg_printf(c, "%s", "\r\n"); // End HTTP headers
4444
} else if (ev == MG_EV_WRITE && c->send.len < MG_IO_SIZE) {
@@ -53,7 +53,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
5353
MG_DEBUG(("MSG"));
5454
// Response is received. Print it
5555
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
56-
printf("%.*s", (int) hm->body.len, hm->body.ptr);
56+
printf("%.*s", (int) hm->body.len, hm->body.buf);
5757
c->is_draining = 1; // Tell mongoose to close this connection
5858
mg_fs_close(fd);
5959
*(bool *) c->fn_data = true; // Tell event loop to stop

examples/file-transfer/server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static void handle_uploads(struct mg_connection *c, int ev, void *ev_data) {
5858
} else {
5959
char fpath[MG_PATH_MAX];
6060
snprintf(fpath, MG_PATH_MAX, "%s%c", s_upld_dir, MG_DIRSEP);
61-
strncat(fpath, hm->uri.ptr + 8, hm->uri.len - 8);
61+
strncat(fpath, hm->uri.buf + 8, hm->uri.len - 8);
6262
if (!mg_path_is_sane(fpath)) {
6363
mg_http_reply(c, 400, "", "Invalid path\n");
6464
c->is_draining = 1; // Tell mongoose to close this connection

examples/file-upload-html-form/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ static void cb(struct mg_connection *c, int ev, void *ev_data) {
2020
if (ev == MG_EV_HTTP_MSG) {
2121
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
2222
MG_INFO(("New request to: [%.*s], body size: %lu", (int) hm->uri.len,
23-
hm->uri.ptr, (unsigned long) hm->body.len));
23+
hm->uri.buf, (unsigned long) hm->body.len));
2424
if (mg_http_match_uri(hm, "/upload")) {
2525
struct mg_http_part part;
2626
size_t ofs = 0;
2727
while ((ofs = mg_http_next_multipart(hm->body, ofs, &part)) > 0) {
2828
MG_INFO(("Chunk name: [%.*s] filename: [%.*s] length: %lu bytes",
29-
(int) part.name.len, part.name.ptr, (int) part.filename.len,
30-
part.filename.ptr, (unsigned long) part.body.len));
29+
(int) part.name.len, part.name.buf, (int) part.filename.len,
30+
part.filename.buf, (unsigned long) part.body.len));
3131
}
3232
mg_http_reply(c, 200, "", "Thank you!");
3333
} else {

examples/file-upload-single-post/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static void handle_uploads(struct mg_connection *c, int ev, void *ev_data) {
2828
if (mg_match(hm->uri, mg_str("/upload/*"), NULL)) {
2929
char path[MG_PATH_MAX];
3030
mg_snprintf(path, sizeof(path), "%s/%.*s", UPLOAD_DIR, hm->uri.len - 8,
31-
hm->uri.ptr + 8);
31+
hm->uri.buf + 8);
3232
us->expected = hm->body.len; // Store number of bytes we expect
3333
mg_iobuf_del(&c->recv, 0, hm->head.len); // Delete HTTP headers
3434
c->pfn = NULL; // Silence HTTP protocol handler, we'll use MG_EV_READ

examples/http-client/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
4343
"Content-Length: %d\r\n"
4444
"\r\n",
4545
s_post_data ? "POST" : "GET", mg_url_uri(s_url), (int) host.len,
46-
host.ptr, content_length);
46+
host.buf, content_length);
4747
mg_send(c, s_post_data, content_length);
4848
} else if (ev == MG_EV_HTTP_MSG) {
4949
// Response is received. Print it
5050
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
51-
printf("%.*s", (int) hm->message.len, hm->message.ptr);
51+
printf("%.*s", (int) hm->message.len, hm->message.buf);
5252
c->is_draining = 1; // Tell mongoose to close this connection
5353
*(bool *) c->fn_data = true; // Tell event loop to stop
5454
} else if (ev == MG_EV_ERROR) {

0 commit comments

Comments
 (0)