@@ -211,7 +211,7 @@ static void handle_firmware_upload(struct mg_connection *c,
211
211
mg_http_reply (c , 500 , "" , "offset and total not set\n" );
212
212
} else if (ofs == 0 && mg_ota_begin ((size_t ) tot ) == false) {
213
213
mg_http_reply (c , 500 , "" , "mg_ota_begin(%ld) failed\n" , tot );
214
- } else if (data .len > 0 && mg_ota_write (data .ptr , data .len ) == false) {
214
+ } else if (data .len > 0 && mg_ota_write (data .buf , data .len ) == false) {
215
215
mg_http_reply (c , 500 , "" , "mg_ota_write(%lu) @%ld failed\n" , data .len , ofs );
216
216
mg_ota_end ();
217
217
} else if (data .len == 0 && mg_ota_end () == false) {
@@ -274,33 +274,33 @@ static void ev_handler(struct mg_connection *c, int ev, void *ev_data) {
274
274
struct mg_http_message * hm = (struct mg_http_message * ) ev_data ;
275
275
struct user * u = authenticate (hm );
276
276
277
- if (mg_http_match_uri (hm , "/api/#" ) && u == NULL ) {
277
+ if (mg_match (hm -> uri , mg_str ( "/api/#" ), NULL ) && u == NULL ) {
278
278
mg_http_reply (c , 403 , "" , "Not Authorised\n" );
279
- } else if (mg_http_match_uri (hm , "/api/login" )) {
279
+ } else if (mg_match (hm -> uri , mg_str ( "/api/login" ), NULL )) {
280
280
handle_login (c , u );
281
- } else if (mg_http_match_uri (hm , "/api/logout" )) {
281
+ } else if (mg_match (hm -> uri , mg_str ( "/api/logout" ), NULL )) {
282
282
handle_logout (c );
283
- } else if (mg_http_match_uri (hm , "/api/debug" )) {
283
+ } else if (mg_match (hm -> uri , mg_str ( "/api/debug" ), NULL )) {
284
284
handle_debug (c , hm );
285
- } else if (mg_http_match_uri (hm , "/api/stats/get" )) {
285
+ } else if (mg_match (hm -> uri , mg_str ( "/api/stats/get" ), NULL )) {
286
286
handle_stats_get (c );
287
- } else if (mg_http_match_uri (hm , "/api/events/get" )) {
287
+ } else if (mg_match (hm -> uri , mg_str ( "/api/events/get" ), NULL )) {
288
288
handle_events_get (c , hm );
289
- } else if (mg_http_match_uri (hm , "/api/settings/get" )) {
289
+ } else if (mg_match (hm -> uri , mg_str ( "/api/settings/get" ), NULL )) {
290
290
handle_settings_get (c );
291
- } else if (mg_http_match_uri (hm , "/api/settings/set" )) {
291
+ } else if (mg_match (hm -> uri , mg_str ( "/api/settings/set" ), NULL )) {
292
292
handle_settings_set (c , hm -> body );
293
- } else if (mg_http_match_uri (hm , "/api/firmware/upload" )) {
293
+ } else if (mg_match (hm -> uri , mg_str ( "/api/firmware/upload" ), NULL )) {
294
294
handle_firmware_upload (c , hm );
295
- } else if (mg_http_match_uri (hm , "/api/firmware/commit" )) {
295
+ } else if (mg_match (hm -> uri , mg_str ( "/api/firmware/commit" ), NULL )) {
296
296
handle_firmware_commit (c );
297
- } else if (mg_http_match_uri (hm , "/api/firmware/rollback" )) {
297
+ } else if (mg_match (hm -> uri , mg_str ( "/api/firmware/rollback" ), NULL )) {
298
298
handle_firmware_rollback (c );
299
- } else if (mg_http_match_uri (hm , "/api/firmware/status" )) {
299
+ } else if (mg_match (hm -> uri , mg_str ( "/api/firmware/status" ), NULL )) {
300
300
handle_firmware_status (c );
301
- } else if (mg_http_match_uri (hm , "/api/device/reset" )) {
301
+ } else if (mg_match (hm -> uri , mg_str ( "/api/device/reset" ), NULL )) {
302
302
handle_device_reset (c );
303
- } else if (mg_http_match_uri (hm , "/api/device/eraselast" )) {
303
+ } else if (mg_match (hm -> uri , mg_str ( "/api/device/eraselast" ), NULL )) {
304
304
handle_device_eraselast (c );
305
305
} else {
306
306
struct mg_http_serve_opts opts ;
@@ -310,7 +310,7 @@ static void ev_handler(struct mg_connection *c, int ev, void *ev_data) {
310
310
mg_http_serve_dir (c , ev_data , & opts );
311
311
}
312
312
MG_DEBUG (("%lu %.*s %.*s -> %.*s" , c -> id , (int ) hm -> method .len ,
313
- hm -> method .ptr , (int ) hm -> uri .len , hm -> uri .ptr , (int ) 3 ,
313
+ hm -> method .buf , (int ) hm -> uri .len , hm -> uri .buf , (int ) 3 ,
314
314
& c -> send .buf [9 ]));
315
315
}
316
316
}
0 commit comments