mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-20 11:19:56 +00:00
cleanup 'str' API
This commit is contained in:
1 parent
6c7672f4af
commit
3c531897b6
20 files changed
+350
-400
No files matched your search
@@ -48,8 +48,10 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
||||
mg_http_reply(c, 200, "Host: foo.com\r\n", "hi\n");
|
||||
} else {
|
||||
// Multithreading code path
|
||||
struct thread_data *data = calloc(1, sizeof(*data)); // Worker owns it
|
||||
data->message = mg_strdup(hm->message); // Pass message
|
||||
struct thread_data *data =
|
||||
(struct thread_data *) calloc(1, sizeof(*data)); // Worker owns it
|
||||
data->message.buf = mg_mprintf("%.*s", hm->message.len, hm->message.buf);
|
||||
data->message.len = hm->message.len; // Pass message
|
||||
data->conn_id = c->id;
|
||||
data->mgr = c->mgr;
|
||||
start_thread(thread_function, data); // Start thread and pass data
|
||||
|
||||
@@ -80,7 +80,8 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
||||
while ((pos = mg_mqtt_next_sub(mm, &topic, &qos, pos)) > 0) {
|
||||
struct sub *sub = calloc(1, sizeof(*sub));
|
||||
sub->c = c;
|
||||
sub->topic = mg_strdup(topic);
|
||||
sub->topic.buf = mg_mprintf("%.*s", topic.len, topic.buf);
|
||||
sub->topic.len = topic.len;
|
||||
sub->qos = qos;
|
||||
LIST_ADD_HEAD(struct sub, &s_subs, sub);
|
||||
MG_INFO(
|
||||
|
||||
@@ -19,11 +19,11 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
||||
size_t i, max = sizeof(hm.headers) / sizeof(hm.headers[0]);
|
||||
// Iterate over request headers
|
||||
for (i = 0; i < max && hm.headers[i].name.len > 0; i++) {
|
||||
struct mg_str *k = &hm.headers[i].name, *v = &hm.headers[i].value;
|
||||
if ((mg_vcasecmp(k, "SERVER") == 0) ||
|
||||
(mg_vcasecmp(k, "LOCATION") == 0)) {
|
||||
printf("\t%.*s -> %.*s\n", (int) k->len, k->buf, (int) v->len,
|
||||
v->buf);
|
||||
struct mg_str k = hm.headers[i].name, v = hm.headers[i].value;
|
||||
if ((mg_strcasecmp(k, mg_str("SERVER")) == 0) ||
|
||||
(mg_strcasecmp(k, mg_str("LOCATION")) == 0)) {
|
||||
printf("\t%.*s -> %.*s\n", (int) k.len, k.buf, (int) v.len,
|
||||
v.buf);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
Reference in new issue
Block a user