Skip to content

Commit cfdd44d

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

File tree

60 files changed

+683
-685
lines changed

Some content is hidden

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

60 files changed

+683
-685
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-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) {

examples/http-proxy-client/main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
1515
static bool connected;
1616
if (ev == MG_EV_HTTP_MSG) {
1717
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
18-
printf("%.*s", (int) hm->message.len, hm->message.ptr);
18+
printf("%.*s", (int) hm->message.len, hm->message.buf);
1919
exit(EXIT_SUCCESS);
2020
} else if (ev == MG_EV_CONNECT) {
2121
// Proxy TCP connection established. Send CONNECT request
@@ -29,8 +29,8 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
2929

3030
// c->is_hexdumping = 1;
3131
mg_printf(c, "CONNECT %.*s:%hu HTTP/1.1\r\nHost: %.*s:%hu\r\n\r\n",
32-
(int) host.len, host.ptr, mg_url_port(url), (int) host.len,
33-
host.ptr, mg_url_port(url));
32+
(int) host.len, host.buf, mg_url_port(url), (int) host.len,
33+
host.buf, mg_url_port(url));
3434
} else if (!connected && ev == MG_EV_READ) {
3535
struct mg_http_message hm;
3636
int n = mg_http_parse((char *) c->recv.buf, c->recv.len, &hm);
@@ -39,14 +39,14 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
3939
// CONNECT response - tunnel is established
4040
connected = true;
4141
MG_DEBUG(
42-
("Connected to proxy, status: %.*s", (int) hm.uri.len, hm.uri.ptr));
42+
("Connected to proxy, status: %.*s", (int) hm.uri.len, hm.uri.buf));
4343
mg_iobuf_del(&c->recv, 0, n);
4444
// Send request to the target server
4545
mg_printf(c,
4646
"GET %s HTTP/1.0\r\n"
4747
"Host: %.*s\r\n"
4848
"\r\n",
49-
mg_url_uri(url), (int) host.len, host.ptr);
49+
mg_url_uri(url), (int) host.len, host.buf);
5050
}
5151
}
5252
}

examples/http-restful-server/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
8383
mg_http_printf_chunk(c, ""); // Don't forget the last empty chunk
8484
} else if (mg_http_match_uri(hm, "/api/f2/*")) {
8585
mg_http_reply(c, 200, "", "{\"result\": \"%.*s\"}\n", (int) hm->uri.len,
86-
hm->uri.ptr);
86+
hm->uri.buf);
8787
} else {
8888
struct mg_http_serve_opts opts = {.root_dir = s_root_dir};
8989
mg_http_serve_dir(c, ev_data, &opts);

examples/http-reverse-proxy/main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ static void forward_request(struct mg_http_message *hm,
2323
size_t i, max = sizeof(hm->headers) / sizeof(hm->headers[0]);
2424
struct mg_str host = mg_url_host(s_backend_url);
2525
mg_printf(c, "%.*s\r\n",
26-
(int) (hm->proto.ptr + hm->proto.len - hm->message.ptr),
27-
hm->message.ptr);
26+
(int) (hm->proto.buf + hm->proto.len - hm->message.buf),
27+
hm->message.buf);
2828
for (i = 0; i < max && hm->headers[i].name.len > 0; i++) {
2929
struct mg_str *k = &hm->headers[i].name, *v = &hm->headers[i].value;
3030
if (mg_strcmp(*k, mg_str("Host")) == 0) v = &host;
31-
mg_printf(c, "%.*s: %.*s\r\n", (int) k->len, k->ptr, (int) v->len, v->ptr);
31+
mg_printf(c, "%.*s: %.*s\r\n", (int) k->len, k->buf, (int) v->len, v->buf);
3232
}
3333
mg_send(c, "\r\n", 2);
34-
mg_send(c, hm->body.ptr, hm->body.len);
35-
MG_DEBUG(("FORWARDING: %.*s %.*s", (int) hm->method.len, hm->method.ptr,
36-
(int) hm->uri.len, hm->uri.ptr));
34+
mg_send(c, hm->body.buf, hm->body.len);
35+
MG_DEBUG(("FORWARDING: %.*s %.*s", (int) hm->method.len, hm->method.buf,
36+
(int) hm->uri.len, hm->uri.buf));
3737
}
3838

3939
static void fn2(struct mg_connection *c, int ev, void *ev_data) {

examples/http-server/main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ static void cb(struct mg_connection *c, int ev, void *ev_data) {
3333
while ((pos = mg_http_next_multipart(hm->body, pos, &part)) > 0) {
3434
char path[MG_PATH_MAX];
3535
MG_INFO(("Chunk name: [%.*s] filename: [%.*s] length: %lu bytes",
36-
part.name.len, part.name.ptr, part.filename.len,
37-
part.filename.ptr, part.body.len));
36+
part.name.len, part.name.buf, part.filename.len,
37+
part.filename.buf, part.body.len));
3838
mg_snprintf(path, sizeof(path), "%s/%.*s", s_upload_dir,
39-
part.filename.len, part.filename.ptr);
39+
part.filename.len, part.filename.buf);
4040
if (mg_path_is_sane(path)) {
41-
mg_file_write(&mg_fs_posix, path, part.body.ptr, part.body.len);
41+
mg_file_write(&mg_fs_posix, path, part.body.buf, part.body.len);
4242
total_bytes += part.body.len;
4343
num_files++;
4444
} else {
@@ -57,8 +57,8 @@ static void cb(struct mg_connection *c, int ev, void *ev_data) {
5757
}
5858

5959
// Log request
60-
MG_INFO(("%.*s %.*s %lu -> %.*s %lu", hm->method.len, hm->method.ptr,
61-
hm->uri.len, hm->uri.ptr, hm->body.len, 3, c->send.buf + 9,
60+
MG_INFO(("%.*s %.*s %lu -> %.*s %lu", hm->method.len, hm->method.buf,
61+
hm->uri.len, hm->uri.buf, hm->body.len, 3, c->send.buf + 9,
6262
c->send.len));
6363
}
6464
}

examples/http-streaming-client/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
3030
"Connection: close\r\n"
3131
"Host: %.*s\r\n"
3232
"\r\n",
33-
mg_url_uri(s_url), (int) host.len, host.ptr);
33+
mg_url_uri(s_url), (int) host.len, host.buf);
3434
} else if (ev == MG_EV_READ) {
3535
// c->data[0] holds a flag, whether we have parsed the request already
3636
if (c->data[0] == 0) {

examples/huge-response/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
4848
const char *headers = "content-type: text/json\r\n";
4949
long start = getparam(hm, "$.start");
5050
long version = getparam(hm, "$.version");
51-
MG_DEBUG(("%.*s", (int) hm->body.len, hm->body.ptr));
51+
MG_DEBUG(("%.*s", (int) hm->body.len, hm->body.buf));
5252
if (version > 0 && version != s_version) {
5353
// Version mismatch: s_data has changed while client fetches it
5454
// Tell client to restart

examples/microchip/same54-xpro/mqtt-client/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,20 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
4848
sub_opts.topic = subt;
4949
sub_opts.qos = s_qos;
5050
mg_mqtt_sub(c, &sub_opts);
51-
MG_INFO(("%lu SUBSCRIBED to %.*s", c->id, (int) subt.len, subt.ptr));
51+
MG_INFO(("%lu SUBSCRIBED to %.*s", c->id, (int) subt.len, subt.buf));
5252
struct mg_mqtt_opts pub_opts;
5353
memset(&pub_opts, 0, sizeof(pub_opts));
5454
pub_opts.topic = pubt;
5555
pub_opts.message = data;
5656
pub_opts.qos = s_qos, pub_opts.retain = false;
5757
mg_mqtt_pub(c, &pub_opts);
58-
MG_INFO(("%lu PUBLISHED %.*s -> %.*s", c->id, (int) data.len, data.ptr,
59-
(int) pubt.len, pubt.ptr));
58+
MG_INFO(("%lu PUBLISHED %.*s -> %.*s", c->id, (int) data.len, data.buf,
59+
(int) pubt.len, pubt.buf));
6060
} else if (ev == MG_EV_MQTT_MSG) {
6161
// When we get echo response, print it
6262
struct mg_mqtt_message *mm = (struct mg_mqtt_message *) ev_data;
6363
MG_INFO(("%lu RECEIVED %.*s <- %.*s", c->id, (int) mm->data.len,
64-
mm->data.ptr, (int) mm->topic.len, mm->topic.ptr));
64+
mm->data.buf, (int) mm->topic.len, mm->topic.buf));
6565
} else if (ev == MG_EV_CLOSE) {
6666
MG_INFO(("%lu CLOSED", c->id));
6767
s_conn = NULL; // Mark that we're closed

examples/mip-pcap/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static void fn2(struct mg_connection *c, int ev, void *ev_data) {
4646
if (ev == MG_EV_HTTP_MSG) {
4747
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
4848
MG_DEBUG(("Got response (%d) %.*s...", (int) hm->message.len, 12,
49-
hm->message.ptr));
49+
hm->message.buf));
5050
c->is_draining = 1;
5151
} else if (ev == MG_EV_CONNECT) {
5252
mg_printf(c, "GET %s HTTP/1.1\r\n\r\n", mg_url_uri((char *) c->fn_data));
@@ -72,7 +72,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
7272
}
7373
} else {
7474
mg_http_reply(c, 200, NULL, "%.*s\r\n", (int) hm->message.len,
75-
hm->message.ptr);
75+
hm->message.buf);
7676
}
7777
}
7878
(void) ev_data;

examples/modbus-dashboard/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ static void signal_handler(int sig_num) {
1515
bool web_load_settings(void *buf, size_t len) {
1616
bool ok = false;
1717
struct mg_str data = mg_file_read(&mg_fs_posix, CONFIG_FILE);
18-
if (data.ptr == NULL) {
18+
if (data.buf == NULL) {
1919
MG_ERROR(("Error reading %s", CONFIG_FILE));
2020
} else if (data.len != len) {
2121
MG_ERROR(("%s size != %lu", CONFIG_FILE, len));
2222
} else {
23-
memcpy(buf, data.ptr, len);
23+
memcpy(buf, data.buf, len);
2424
}
25-
free((void *) data.ptr);
25+
free((void *) data.buf);
2626
return ok;
2727
}
2828

examples/modbus-dashboard/net.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static struct mg_connection *start_modbus_request(struct mg_mgr *mgr,
138138
uint16_t reg = (uint16_t) mg_json_get_long(json, "$.reg", 1);
139139
uint8_t func = (uint8_t) mg_json_get_long(json, "$.func", 0);
140140
uint16_t nregs = (uint16_t) mg_json_get_long(json, "$.nregs", 1);
141-
MG_INFO(("%lu REQUEST: %.*s", cid, json.len, json.ptr));
141+
MG_INFO(("%lu REQUEST: %.*s", cid, json.len, json.buf));
142142
if (func == 0) {
143143
MG_ERROR(("Set func to a valid modbus function code"));
144144
} else if ((c = mg_connect(mgr, url, mfn, NULL)) == NULL) {
@@ -275,8 +275,8 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
275275
#endif
276276
mg_http_serve_dir(c, ev_data, &opts);
277277
}
278-
MG_DEBUG(("%lu %.*s %.*s", c->id, (int) hm->method.len, hm->method.ptr,
279-
(int) hm->uri.len, hm->uri.ptr));
278+
MG_DEBUG(("%lu %.*s %.*s", c->id, (int) hm->method.len, hm->method.buf,
279+
(int) hm->uri.len, hm->uri.buf));
280280
} else if (ev == MG_EV_POLL) {
281281
if (cd->expiration_time > 0 && cd->expiration_time < mg_millis()) {
282282
cd->expiration_time = 0;

examples/mqtt-client-aws-iot/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
6464
} else if (ev == MG_EV_MQTT_MSG) {
6565
// When we receive MQTT message, print it
6666
struct mg_mqtt_message *mm = (struct mg_mqtt_message *) ev_data;
67-
MG_INFO(("Received on %.*s : %.*s", (int) mm->topic.len, mm->topic.ptr,
68-
(int) mm->data.len, mm->data.ptr));
67+
MG_INFO(("Received on %.*s : %.*s", (int) mm->topic.len, mm->topic.buf,
68+
(int) mm->data.len, mm->data.buf));
6969
} else if (ev == MG_EV_POLL && c->data[0] == 'X') {
7070
static unsigned long prev_second;
7171
unsigned long now_second = (*(unsigned long *) ev_data) / 1000;

examples/mqtt-client/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,20 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
4747
sub_opts.topic = subt;
4848
sub_opts.qos = s_qos;
4949
mg_mqtt_sub(c, &sub_opts);
50-
MG_INFO(("%lu SUBSCRIBED to %.*s", c->id, (int) subt.len, subt.ptr));
50+
MG_INFO(("%lu SUBSCRIBED to %.*s", c->id, (int) subt.len, subt.buf));
5151
struct mg_mqtt_opts pub_opts;
5252
memset(&pub_opts, 0, sizeof(pub_opts));
5353
pub_opts.topic = pubt;
5454
pub_opts.message = data;
5555
pub_opts.qos = s_qos, pub_opts.retain = false;
5656
mg_mqtt_pub(c, &pub_opts);
57-
MG_INFO(("%lu PUBLISHED %.*s -> %.*s", c->id, (int) data.len, data.ptr,
58-
(int) pubt.len, pubt.ptr));
57+
MG_INFO(("%lu PUBLISHED %.*s -> %.*s", c->id, (int) data.len, data.buf,
58+
(int) pubt.len, pubt.buf));
5959
} else if (ev == MG_EV_MQTT_MSG) {
6060
// When we get echo response, print it
6161
struct mg_mqtt_message *mm = (struct mg_mqtt_message *) ev_data;
6262
MG_INFO(("%lu RECEIVED %.*s <- %.*s", c->id, (int) mm->data.len,
63-
mm->data.ptr, (int) mm->topic.len, mm->topic.ptr));
63+
mm->data.buf, (int) mm->topic.len, mm->topic.buf));
6464
} else if (ev == MG_EV_CLOSE) {
6565
MG_INFO(("%lu CLOSED", c->id));
6666
s_conn = NULL; // Mark that we're closed

0 commit comments

Comments
 (0)