diff --git a/Plugson/src/Web/ventoy_http.c b/Plugson/src/Web/ventoy_http.c index ac5c1797..17ff421d 100644 --- a/Plugson/src/Web/ventoy_http.c +++ b/Plugson/src/Web/ventoy_http.c @@ -6,12 +6,12 @@ * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * @@ -47,16 +47,16 @@ #include #include "fat_filelib.h" -static const char *g_json_title_postfix[bios_max + 1] = +static const char *g_json_title_postfix[bios_max + 1] = { "", "_legacy", "_uefi", "_ia32", "_aa64", "_mips", "" }; static const char *g_ventoy_kbd_layout[] = { - "QWERTY_USA", "AZERTY", "CZECH_QWERTY", "CZECH_QWERTZ", "DANISH", - "DVORAK_USA", "FRENCH", "GERMAN", "ITALIANO", "JAPAN_106", "LATIN_USA", - "PORTU_BRAZIL", "QWERTY_UK", "QWERTZ", "QWERTZ_HUN", "QWERTZ_SLOV_CROAT", + "QWERTY_USA", "AZERTY", "CZECH_QWERTY", "CZECH_QWERTZ", "DANISH", + "DVORAK_USA", "FRENCH", "GERMAN", "ITALIANO", "JAPAN_106", "LATIN_USA", + "PORTU_BRAZIL", "QWERTY_UK", "QWERTZ", "QWERTZ_HUN", "QWERTZ_SLOV_CROAT", "SPANISH", "SWEDISH", "TURKISH_Q", "VIETNAMESE", NULL }; @@ -64,11 +64,11 @@ static const char *g_ventoy_kbd_layout[] = #define VTOY_DEL_ALL_PATH "4119ae33-98ea-448e-b9c0-569aafcf1fb4" static int g_json_exist[plugin_type_max][bios_max]; -static const char *g_plugin_name[plugin_type_max] = +static const char *g_plugin_name[plugin_type_max] = { - "control", "theme", "menu_alias", "menu_tip", - "menu_class", "auto_install", "persistence", "injection", - "conf_replace", "password", "image_list", + "control", "theme", "menu_alias", "menu_tip", + "menu_class", "auto_install", "persistence", "injection", + "conf_replace", "password", "image_list", "auto_memdisk", "dud" }; @@ -104,7 +104,7 @@ static struct mg_context *g_ventoy_http_ctx = NULL; static int ventoy_is_kbd_valid(const char *key) { int i = 0; - + for (i = 0; g_ventoy_kbd_layout[i]; i++) { if (strcmp(g_ventoy_kbd_layout[i], key) == 0) @@ -119,7 +119,7 @@ static int ventoy_is_kbd_valid(const char *key) static const char * ventoy_real_path(const char *org) { int count = 0; - + if (g_sysinfo.pathcase) { scnprintf(g_pub_path, MAX_PATH, "%s", org); @@ -139,7 +139,7 @@ static const char * ventoy_real_path(const char *org) static int ventoy_json_result(struct mg_connection *conn, const char *err) { - mg_printf(conn, + mg_printf(conn, "HTTP/1.1 200 OK \r\n" "Content-Type: application/json\r\n" "Content-Length: %d\r\n" @@ -151,12 +151,12 @@ static int ventoy_json_result(struct mg_connection *conn, const char *err) static int ventoy_json_buffer(struct mg_connection *conn, const char *json_buf, int json_len) { - mg_printf(conn, + mg_printf(conn, "HTTP/1.1 200 OK \r\n" "Content-Type: application/json\r\n" "Content-Length: %d\r\n" "\r\n%s", - json_len, json_buf); + json_len, json_buf); return 0; } @@ -171,7 +171,7 @@ static void ventoy_free_path_node_list(path_node *list) next = node->next; free(node); node = next; - } + } } static int ventoy_path_is_real_exist(const char *path, void *head, size_t pathoff, size_t nextoff) @@ -201,7 +201,7 @@ static int ventoy_path_is_real_exist(const char *path, void *head, size_t pathof return 1; } } - + memcpy(&node, node + nextoff, sizeof(node)); } @@ -219,7 +219,7 @@ static path_node * ventoy_path_node_add_array(VTOY_JSON *array) { node = zalloc(sizeof(path_node)); if (node) - { + { scnprintf(node->path, sizeof(node->path), "%s", item->unData.pcStrVal); vtoy_list_add(head, cur, node); } @@ -234,7 +234,7 @@ static int ventoy_check_fuzzy_path(char *path, int prefix) char c; char *cur = NULL; char *pos = NULL; - + if (!path) { return 0; @@ -250,7 +250,7 @@ static int ventoy_check_fuzzy_path(char *path, int prefix) return 0; } } - + while (pos != path) { if (*pos == '/') @@ -293,11 +293,11 @@ static int ventoy_check_fuzzy_path(char *path, int prefix) { if (prefix) { - return ventoy_is_file_exist("%s%s", g_cur_dir, path); + return ventoy_is_file_exist("%s%s", g_cur_dir, path); } else { - return ventoy_is_file_exist("%s", path); + return ventoy_is_file_exist("%s", path); } } } @@ -316,7 +316,7 @@ static int ventoy_path_list_cmp(path_node *list1, path_node *list2) { return 1; } - + list1 = list1->next; list2 = list2->next; } @@ -337,12 +337,12 @@ static int ventoy_path_list_cmp(path_node *list1, path_node *list2) static int ventoy_api_device_info(struct mg_connection *conn, VTOY_JSON *json) { int pos = 0; - + (void)json; VTOY_JSON_FMT_BEGIN(pos, JSON_BUFFER, JSON_BUF_MAX); VTOY_JSON_FMT_OBJ_BEGIN(); - + VTOY_JSON_FMT_STRN("dev_name", g_sysinfo.cur_model); VTOY_JSON_FMT_STRN("dev_capacity", g_sysinfo.cur_capacity); VTOY_JSON_FMT_STRN("dev_fs", g_sysinfo.cur_fsname); @@ -360,7 +360,7 @@ static int ventoy_api_device_info(struct mg_connection *conn, VTOY_JSON *json) static int ventoy_api_sysinfo(struct mg_connection *conn, VTOY_JSON *json) { int pos = 0; - + (void)json; VTOY_JSON_FMT_BEGIN(pos, JSON_BUFFER, JSON_BUF_MAX); @@ -371,10 +371,10 @@ static int ventoy_api_sysinfo(struct mg_connection *conn, VTOY_JSON *json) //read clear VTOY_JSON_FMT_SINT("syntax_error", g_sysinfo.syntax_error); g_sysinfo.syntax_error = 0; - + VTOY_JSON_FMT_SINT("invalid_config", g_sysinfo.invalid_config); g_sysinfo.invalid_config = 0; - + #if defined(_MSC_VER) || defined(WIN32) VTOY_JSON_FMT_STRN("os", "windows"); #else @@ -394,7 +394,7 @@ static int ventoy_api_handshake(struct mg_connection *conn, VTOY_JSON *json) int j = 0; int pos = 0; char key[128]; - + (void)json; VTOY_JSON_FMT_BEGIN(pos, JSON_BUFFER, JSON_BUF_MAX); @@ -414,7 +414,7 @@ static int ventoy_api_handshake(struct mg_connection *conn, VTOY_JSON *json) } VTOY_JSON_FMT_ARY_ENDEX(); } - + VTOY_JSON_FMT_OBJ_END(); VTOY_JSON_FMT_END(pos); @@ -483,7 +483,7 @@ static int ventoy_api_check_exist2(struct mg_connection *conn, VTOY_JSON *json) { if (fuzzy1) { - exist1 = ventoy_check_fuzzy_path((char *)path1, 0); + exist1 = ventoy_check_fuzzy_path((char *)path1, 0); } else { @@ -491,7 +491,7 @@ static int ventoy_api_check_exist2(struct mg_connection *conn, VTOY_JSON *json) } } } - + if (path2) { if (dir2) @@ -502,7 +502,7 @@ static int ventoy_api_check_exist2(struct mg_connection *conn, VTOY_JSON *json) { if (fuzzy2) { - exist2 = ventoy_check_fuzzy_path((char *)path2, 0); + exist2 = ventoy_check_fuzzy_path((char *)path2, 0); } else { @@ -559,7 +559,9 @@ void ventoy_data_default_control(data_control *data) data->secondary_menu_timeout = 0; data->win11_bypass_check = 1; data->win11_bypass_nro = 1; - + data->uefi_res_lock = 3; + data->uefi_sb_policy = 0; + strlcpy(data->default_kbd_layout, "QWERTY_USA"); strlcpy(data->menu_language, "en_US"); } @@ -584,6 +586,8 @@ int ventoy_data_cmp_control(data_control *data1, data_control *data2) data1->password_asterisk != data2->password_asterisk || data1->secondary_menu != data2->secondary_menu || data1->menu_timeout != data2->menu_timeout || + data1->uefi_res_lock != data2->uefi_res_lock || + data1->uefi_sb_policy != data2->uefi_sb_policy || data1->secondary_menu_timeout != data2->secondary_menu_timeout) { return 1; @@ -604,22 +608,22 @@ int ventoy_data_save_control(data_control *data, const char *title, char *buf, i { int pos = 0; data_control *def = g_data_control + bios_max; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_KEY_L(L1, title); VTOY_JSON_FMT_ARY_BEGIN_N(); - VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_DEFAULT_MENU_MODE", default_menu_mode); + VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_DEFAULT_MENU_MODE", default_menu_mode); VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_TREE_VIEW_MENU_STYLE", treeview_style); VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_FILT_DOT_UNDERSCORE_FILE", filter_dot_underscore); VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_SORT_CASE_SENSITIVE", sort_casesensitive); if (data->max_search_level >= 0) { - VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_MAX_SEARCH_LEVEL", max_search_level); + VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_MAX_SEARCH_LEVEL", max_search_level); } - + VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_VHD_NO_WARNING", vhd_no_warning); VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_FILE_FLT_ISO", filter_iso); VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_FILE_FLT_WIM", filter_wim); @@ -633,16 +637,18 @@ int ventoy_data_save_control(data_control *data, const char *title, char *buf, i VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_SECONDARY_BOOT_MENU", secondary_menu); VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_SHOW_PASSWORD_ASTERISK", password_asterisk); VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_MENU_TIMEOUT", menu_timeout); + VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_WIN_UEFI_RES_LOCK", uefi_res_lock); + VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_SECURE_BOOT_POLICY", uefi_sb_policy); VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_SECONDARY_TIMEOUT", secondary_menu_timeout); - VTOY_JSON_FMT_CTRL_STRN(L2, "VTOY_DEFAULT_KBD_LAYOUT", default_kbd_layout); - VTOY_JSON_FMT_CTRL_STRN(L2, "VTOY_MENU_LANGUAGE", menu_language); + VTOY_JSON_FMT_CTRL_STRN(L2, "VTOY_DEFAULT_KBD_LAYOUT", default_kbd_layout); + VTOY_JSON_FMT_CTRL_STRN(L2, "VTOY_MENU_LANGUAGE", menu_language); if (strcmp(def->default_search_root, data->default_search_root)) { VTOY_JSON_FMT_CTRL_STRN_STR(L2, "VTOY_DEFAULT_SEARCH_ROOT", ventoy_real_path(data->default_search_root)); } - + if (strcmp(def->default_image, data->default_image)) { VTOY_JSON_FMT_CTRL_STRN_STR(L2, "VTOY_DEFAULT_IMAGE", ventoy_real_path(data->default_image)); @@ -659,7 +665,7 @@ int ventoy_data_json_control(data_control *ctrl, char *buf, int buflen) int i = 0; int pos = 0; int valid = 0; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_OBJ_BEGIN(); @@ -667,9 +673,9 @@ int ventoy_data_json_control(data_control *ctrl, char *buf, int buflen) VTOY_JSON_FMT_SINT("treeview_style", ctrl->treeview_style); VTOY_JSON_FMT_SINT("filter_dot_underscore", ctrl->filter_dot_underscore); VTOY_JSON_FMT_SINT("sort_casesensitive", ctrl->sort_casesensitive); - VTOY_JSON_FMT_SINT("max_search_level", ctrl->max_search_level); + VTOY_JSON_FMT_SINT("max_search_level", ctrl->max_search_level); VTOY_JSON_FMT_SINT("vhd_no_warning", ctrl->vhd_no_warning); - + VTOY_JSON_FMT_SINT("filter_iso", ctrl->filter_iso); VTOY_JSON_FMT_SINT("filter_wim", ctrl->filter_wim); VTOY_JSON_FMT_SINT("filter_efi", ctrl->filter_efi); @@ -682,6 +688,8 @@ int ventoy_data_json_control(data_control *ctrl, char *buf, int buflen) VTOY_JSON_FMT_SINT("secondary_menu", ctrl->secondary_menu); VTOY_JSON_FMT_SINT("password_asterisk", ctrl->password_asterisk); VTOY_JSON_FMT_SINT("menu_timeout", ctrl->menu_timeout); + VTOY_JSON_FMT_SINT("uefi_res_lock", ctrl->uefi_res_lock); + VTOY_JSON_FMT_SINT("uefi_sb_policy", ctrl->uefi_sb_policy); VTOY_JSON_FMT_SINT("secondary_menu_timeout", ctrl->secondary_menu_timeout); VTOY_JSON_FMT_STRN("default_kbd_layout", ctrl->default_kbd_layout); VTOY_JSON_FMT_STRN("menu_language", ctrl->menu_language); @@ -694,7 +702,7 @@ int ventoy_data_json_control(data_control *ctrl, char *buf, int buflen) VTOY_JSON_FMT_STRN("default_search_root", ctrl->default_search_root); VTOY_JSON_FMT_SINT("default_search_root_valid", valid); - + valid = 0; if (ctrl->default_image[0] && ventoy_is_file_exist("%s%s", g_cur_dir, ctrl->default_image)) { @@ -708,10 +716,10 @@ int ventoy_data_json_control(data_control *ctrl, char *buf, int buflen) for (i = 0; g_ventoy_menu_lang[i][0]; i++) { - VTOY_JSON_FMT_ITEM(g_ventoy_menu_lang[i]); + VTOY_JSON_FMT_ITEM(g_ventoy_menu_lang[i]); } VTOY_JSON_FMT_ARY_ENDEX(); - + VTOY_JSON_FMT_OBJ_END(); VTOY_JSON_FMT_END(pos); @@ -729,7 +737,7 @@ static int ventoy_api_save_control(struct mg_connection *conn, VTOY_JSON *json) int ret; int index = 0; data_control *ctrl = NULL; - + vtoy_json_get_int(json, "index", &index); ctrl = g_data_control + index; @@ -751,13 +759,15 @@ static int ventoy_api_save_control(struct mg_connection *conn, VTOY_JSON *json) VTOY_JSON_INT("secondary_menu", ctrl->secondary_menu); VTOY_JSON_INT("password_asterisk", ctrl->password_asterisk); VTOY_JSON_INT("menu_timeout", ctrl->menu_timeout); + VTOY_JSON_INT("uefi_res_lock", ctrl->uefi_res_lock); + VTOY_JSON_INT("uefi_sb_policy", ctrl->uefi_sb_policy); VTOY_JSON_INT("secondary_menu_timeout", ctrl->secondary_menu_timeout); VTOY_JSON_STR("default_image", ctrl->default_image); VTOY_JSON_STR("default_search_root", ctrl->default_search_root); VTOY_JSON_STR("menu_language", ctrl->menu_language); VTOY_JSON_STR("default_kbd_layout", ctrl->default_kbd_layout); - + ret = ventoy_data_save_all(); ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); @@ -808,7 +818,7 @@ int ventoy_data_save_theme(data_theme *data, const char *title, char *buf, int b int pos = 0; path_node *node = NULL; data_theme *def = g_data_theme + bios_max; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_KEY_L(L1, title); @@ -827,15 +837,15 @@ int ventoy_data_save_theme(data_theme *data, const char *title, char *buf, int b } VTOY_JSON_FMT_ARY_ENDEX_LN(L2); - + if (def->default_file != data->default_file) { - VTOY_JSON_FMT_SINT_LN(L2, "default_file", data->default_file); + VTOY_JSON_FMT_SINT_LN(L2, "default_file", data->default_file); } - + if (def->resolution_fit != data->resolution_fit) { - VTOY_JSON_FMT_SINT_LN(L2, "resolution_fit", data->resolution_fit); + VTOY_JSON_FMT_SINT_LN(L2, "resolution_fit", data->resolution_fit); } } else @@ -865,11 +875,11 @@ int ventoy_data_save_theme(data_theme *data, const char *title, char *buf, int b } VTOY_JSON_FMT_DIFF_STRN(L2, "gfxmode", gfxmode); - + VTOY_JSON_FMT_DIFF_STRN(L2, "ventoy_left", ventoy_left); VTOY_JSON_FMT_DIFF_STRN(L2, "ventoy_top", ventoy_top); VTOY_JSON_FMT_DIFF_STRN(L2, "ventoy_color", ventoy_color); - + if (data->fontslist) { VTOY_JSON_FMT_KEY_L(L2, "fonts"); @@ -879,10 +889,10 @@ int ventoy_data_save_theme(data_theme *data, const char *title, char *buf, int b { VTOY_JSON_FMT_ITEM_PATH_LN(L3, node->path); } - + VTOY_JSON_FMT_ARY_ENDEX_LN(L2); } - + VTOY_JSON_FMT_OBJ_ENDEX_LN(L1); VTOY_JSON_FMT_END(pos); @@ -894,7 +904,7 @@ int ventoy_data_json_theme(data_theme *data, char *buf, int buflen) { int pos = 0; path_node *node = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_OBJ_BEGIN(); @@ -902,11 +912,11 @@ int ventoy_data_json_theme(data_theme *data, char *buf, int buflen) VTOY_JSON_FMT_SINT("resolution_fit", data->resolution_fit); VTOY_JSON_FMT_SINT("display_mode", data->display_mode); VTOY_JSON_FMT_STRN("gfxmode", data->gfxmode); - + VTOY_JSON_FMT_STRN("ventoy_color", data->ventoy_color); VTOY_JSON_FMT_STRN("ventoy_left", data->ventoy_left); VTOY_JSON_FMT_STRN("ventoy_top", data->ventoy_top); - + VTOY_JSON_FMT_KEY("filelist"); VTOY_JSON_FMT_ARY_BEGIN(); for (node = data->filelist; node; node = node->next) @@ -917,7 +927,7 @@ int ventoy_data_json_theme(data_theme *data, char *buf, int buflen) VTOY_JSON_FMT_OBJ_ENDEX(); } VTOY_JSON_FMT_ARY_ENDEX(); - + VTOY_JSON_FMT_KEY("fontslist"); VTOY_JSON_FMT_ARY_BEGIN(); for (node = data->fontslist; node; node = node->next) @@ -928,7 +938,7 @@ int ventoy_data_json_theme(data_theme *data, char *buf, int buflen) VTOY_JSON_FMT_OBJ_ENDEX(); } VTOY_JSON_FMT_ARY_ENDEX(); - + VTOY_JSON_FMT_OBJ_END(); VTOY_JSON_FMT_END(pos); @@ -946,7 +956,7 @@ static int ventoy_api_save_theme(struct mg_connection *conn, VTOY_JSON *json) int ret; int index = 0; data_theme *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_theme + index; @@ -960,7 +970,7 @@ static int ventoy_api_save_theme(struct mg_connection *conn, VTOY_JSON *json) ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -973,7 +983,7 @@ static int ventoy_api_theme_add_file(struct mg_connection *conn, VTOY_JSON *json path_node *node = NULL; path_node *cur = NULL; data_theme *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_theme + index; @@ -991,13 +1001,13 @@ static int ventoy_api_theme_add_file(struct mg_connection *conn, VTOY_JSON *json { scnprintf(node->path, sizeof(node->path), "%s", path); - vtoy_list_add(data->filelist, cur, node); + vtoy_list_add(data->filelist, cur, node); } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -1009,7 +1019,7 @@ static int ventoy_api_theme_del_file(struct mg_connection *conn, VTOY_JSON *json path_node *node = NULL; path_node *last = NULL; data_theme *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_theme + index; @@ -1023,12 +1033,12 @@ static int ventoy_api_theme_del_file(struct mg_connection *conn, VTOY_JSON *json else { vtoy_list_del(last, node, data->filelist, path); - } + } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -1063,7 +1073,7 @@ static int ventoy_api_theme_add_font(struct mg_connection *conn, VTOY_JSON *json ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -1076,7 +1086,7 @@ static int ventoy_api_theme_del_font(struct mg_connection *conn, VTOY_JSON *json path_node *node = NULL; path_node *last = NULL; data_theme *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_theme + index; @@ -1089,13 +1099,13 @@ static int ventoy_api_theme_del_font(struct mg_connection *conn, VTOY_JSON *json } else { - vtoy_list_del(last, node, data->fontslist, path); - } + vtoy_list_del(last, node, data->fontslist, path); + } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -1120,16 +1130,16 @@ int ventoy_data_cmp_menu_alias(data_alias *data1, data_alias *data2) { list1 = data1->list; list2 = data2->list; - + while (list1 && list2) { - if ((list1->type != list2->type) || - strcmp(list1->path, list2->path) || + if ((list1->type != list2->type) || + strcmp(list1->path, list2->path) || strcmp(list1->alias, list2->alias)) { return 1; } - + list1 = list1->next; list2 = list2->next; } @@ -1153,7 +1163,7 @@ int ventoy_data_save_menu_alias(data_alias *data, const char *title, char *buf, { int pos = 0; data_alias_node *node = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_KEY_L(L1, title); @@ -1165,15 +1175,15 @@ int ventoy_data_save_menu_alias(data_alias *data, const char *title, char *buf, if (node->type == path_type_file) { - VTOY_JSON_FMT_STRN_PATH_LN(L3, "image", node->path); + VTOY_JSON_FMT_STRN_PATH_LN(L3, "image", node->path); } else { VTOY_JSON_FMT_STRN_PATH_LN(L3, "dir", node->path); } - + VTOY_JSON_FMT_STRN_EX_LN(L3, "alias", node->alias); - + VTOY_JSON_FMT_OBJ_ENDEX_LN(L2); } @@ -1189,7 +1199,7 @@ int ventoy_data_json_menu_alias(data_alias *data, char *buf, int buflen) int pos = 0; int valid = 0; data_alias_node *node = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_ARY_BEGIN(); @@ -1207,10 +1217,10 @@ int ventoy_data_json_menu_alias(data_alias *data, char *buf, int buflen) { valid = ventoy_is_directory_exist("%s%s", g_cur_dir, node->path); } - + VTOY_JSON_FMT_SINT("valid", valid); VTOY_JSON_FMT_STRN("alias", node->alias); - + VTOY_JSON_FMT_OBJ_ENDEX(); } @@ -1231,7 +1241,7 @@ static int ventoy_api_save_alias(struct mg_connection *conn, VTOY_JSON *json) int ret; ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -1245,7 +1255,7 @@ static int ventoy_api_alias_add(struct mg_connection *conn, VTOY_JSON *json) data_alias_node *node = NULL; data_alias_node *cur = NULL; data_alias *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_menu_alias + index; @@ -1267,14 +1277,14 @@ static int ventoy_api_alias_add(struct mg_connection *conn, VTOY_JSON *json) node->type = type; scnprintf(node->path, sizeof(node->path), "%s", path); scnprintf(node->alias, sizeof(node->alias), "%s", alias); - + vtoy_list_add(data->list, cur, node); } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -1286,7 +1296,7 @@ static int ventoy_api_alias_del(struct mg_connection *conn, VTOY_JSON *json) data_alias_node *last = NULL; data_alias_node *node = NULL; data_alias *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_menu_alias + index; @@ -1295,17 +1305,17 @@ static int ventoy_api_alias_del(struct mg_connection *conn, VTOY_JSON *json) { if (strcmp(path, VTOY_DEL_ALL_PATH) == 0) { - vtoy_list_free(data_alias_node, data->list); + vtoy_list_free(data_alias_node, data->list); } else { - vtoy_list_del(last, node, data->list, path); + vtoy_list_del(last, node, data->list, path); } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -1339,16 +1349,16 @@ int ventoy_data_cmp_menu_tip(data_tip *data1, data_tip *data2) { list1 = data1->list; list2 = data2->list; - + while (list1 && list2) { - if ((list1->type != list2->type) || - strcmp(list1->path, list2->path) || + if ((list1->type != list2->type) || + strcmp(list1->path, list2->path) || strcmp(list1->tip, list2->tip)) { return 1; } - + list1 = list1->next; list2 = list2->next; } @@ -1373,14 +1383,14 @@ int ventoy_data_save_menu_tip(data_tip *data, const char *title, char *buf, int int pos = 0; data_tip_node *node = NULL; data_tip *def = g_data_menu_tip + bios_max; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_KEY_L(L1, title); VTOY_JSON_FMT_OBJ_BEGIN_N(); - VTOY_JSON_FMT_DIFF_STRN(L2, "left", left); - VTOY_JSON_FMT_DIFF_STRN(L2, "top", top); - VTOY_JSON_FMT_DIFF_STRN(L2, "color", color); + VTOY_JSON_FMT_DIFF_STRN(L2, "left", left); + VTOY_JSON_FMT_DIFF_STRN(L2, "top", top); + VTOY_JSON_FMT_DIFF_STRN(L2, "color", color); if (data->list) { @@ -1393,22 +1403,22 @@ int ventoy_data_save_menu_tip(data_tip *data, const char *title, char *buf, int if (node->type == path_type_file) { - VTOY_JSON_FMT_STRN_PATH_LN(L4, "image", node->path); + VTOY_JSON_FMT_STRN_PATH_LN(L4, "image", node->path); } else { VTOY_JSON_FMT_STRN_PATH_LN(L4, "dir", node->path); } VTOY_JSON_FMT_STRN_EX_LN(L4, "tip", node->tip); - + VTOY_JSON_FMT_OBJ_ENDEX_LN(L3); } VTOY_JSON_FMT_ARY_ENDEX_LN(L2); } - + VTOY_JSON_FMT_OBJ_ENDEX_LN(L1); - + VTOY_JSON_FMT_END(pos); return pos; @@ -1420,11 +1430,11 @@ int ventoy_data_json_menu_tip(data_tip *data, char *buf, int buflen) int pos = 0; int valid = 0; data_tip_node *node = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_OBJ_BEGIN(); - + VTOY_JSON_FMT_STRN("left", data->left); VTOY_JSON_FMT_STRN("top", data->top); VTOY_JSON_FMT_STRN("color", data->color); @@ -1446,10 +1456,10 @@ int ventoy_data_json_menu_tip(data_tip *data, char *buf, int buflen) { valid = ventoy_is_directory_exist("%s%s", g_cur_dir, node->path); } - + VTOY_JSON_FMT_SINT("valid", valid); VTOY_JSON_FMT_STRN("tip", node->tip); - + VTOY_JSON_FMT_OBJ_ENDEX(); } @@ -1472,7 +1482,7 @@ static int ventoy_api_save_tip(struct mg_connection *conn, VTOY_JSON *json) int ret; int index = 0; data_tip *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_menu_tip + index; @@ -1482,7 +1492,7 @@ static int ventoy_api_save_tip(struct mg_connection *conn, VTOY_JSON *json) ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -1496,7 +1506,7 @@ static int ventoy_api_tip_add(struct mg_connection *conn, VTOY_JSON *json) data_tip_node *node = NULL; data_tip_node *cur = NULL; data_tip *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_menu_tip + index; @@ -1511,21 +1521,21 @@ static int ventoy_api_tip_add(struct mg_connection *conn, VTOY_JSON *json) ventoy_json_result(conn, VTOY_JSON_DUPLICATE); return 0; } - + node = zalloc(sizeof(data_tip_node)); if (node) { node->type = type; scnprintf(node->path, sizeof(node->path), "%s", path); scnprintf(node->tip, sizeof(node->tip), "%s", tip); - + vtoy_list_add(data->list, cur, node); } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -1537,7 +1547,7 @@ static int ventoy_api_tip_del(struct mg_connection *conn, VTOY_JSON *json) data_tip_node *last = NULL; data_tip_node *node = NULL; data_tip *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_menu_tip + index; @@ -1546,17 +1556,17 @@ static int ventoy_api_tip_del(struct mg_connection *conn, VTOY_JSON *json) { if (strcmp(path, VTOY_DEL_ALL_PATH) == 0) { - vtoy_list_free(data_tip_node, data->list); + vtoy_list_free(data_tip_node, data->list); } else { - vtoy_list_del(last, node, data->list, path); + vtoy_list_del(last, node, data->list, path); } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -1581,16 +1591,16 @@ int ventoy_data_cmp_menu_class(data_class *data1, data_class *data2) { list1 = data1->list; list2 = data2->list; - + while (list1 && list2) { - if ((list1->type != list2->type) || - strcmp(list1->path, list2->path) || + if ((list1->type != list2->type) || + strcmp(list1->path, list2->path) || strcmp(list1->class, list2->class)) { return 1; } - + list1 = list1->next; list2 = list2->next; } @@ -1614,7 +1624,7 @@ int ventoy_data_save_menu_class(data_class *data, const char *title, char *buf, { int pos = 0; data_class_node *node = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_KEY_L(L1, title); @@ -1626,7 +1636,7 @@ int ventoy_data_save_menu_class(data_class *data, const char *title, char *buf, if (node->type == class_type_key) { - VTOY_JSON_FMT_STRN_LN(L3, "key", node->path); + VTOY_JSON_FMT_STRN_LN(L3, "key", node->path); } else if (node->type == class_type_dir) { @@ -1637,7 +1647,7 @@ int ventoy_data_save_menu_class(data_class *data, const char *title, char *buf, VTOY_JSON_FMT_STRN_PATH_LN(L3, "parent", node->path); } VTOY_JSON_FMT_STRN_LN(L3, "class", node->class); - + VTOY_JSON_FMT_OBJ_ENDEX_LN(L2); } @@ -1653,7 +1663,7 @@ int ventoy_data_json_menu_class(data_class *data, char *buf, int buflen) int pos = 0; int valid = 0; data_class_node *node = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_ARY_BEGIN(); @@ -1662,7 +1672,7 @@ int ventoy_data_json_menu_class(data_class *data, char *buf, int buflen) VTOY_JSON_FMT_OBJ_BEGIN(); VTOY_JSON_FMT_UINT("type", node->type); - VTOY_JSON_FMT_STRN("path", node->path); + VTOY_JSON_FMT_STRN("path", node->path); if (node->type == class_type_key) { @@ -1673,9 +1683,9 @@ int ventoy_data_json_menu_class(data_class *data, char *buf, int buflen) valid = ventoy_is_directory_exist("%s%s", g_cur_dir, node->path); } VTOY_JSON_FMT_SINT("valid", valid); - + VTOY_JSON_FMT_STRN("class", node->class); - + VTOY_JSON_FMT_OBJ_ENDEX(); } @@ -1697,7 +1707,7 @@ static int ventoy_api_save_class(struct mg_connection *conn, VTOY_JSON *json) int ret; ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -1711,7 +1721,7 @@ static int ventoy_api_class_add(struct mg_connection *conn, VTOY_JSON *json) data_class_node *node = NULL; data_class_node *cur = NULL; data_class *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_menu_class + index; @@ -1725,17 +1735,17 @@ static int ventoy_api_class_add(struct mg_connection *conn, VTOY_JSON *json) if (node) { node->type = type; - + scnprintf(node->path, sizeof(node->path), "%s", path); scnprintf(node->class, sizeof(node->class), "%s", class); - + vtoy_list_add(data->list, cur, node); } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -1747,7 +1757,7 @@ static int ventoy_api_class_del(struct mg_connection *conn, VTOY_JSON *json) data_class_node *last = NULL; data_class_node *node = NULL; data_class *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_menu_class + index; @@ -1760,13 +1770,13 @@ static int ventoy_api_class_del(struct mg_connection *conn, VTOY_JSON *json) } else { - vtoy_list_del(last, node, data->list, path); + vtoy_list_del(last, node, data->list, path); } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -1787,7 +1797,7 @@ int ventoy_data_save_auto_memdisk(data_auto_memdisk *data, const char *title, ch { int pos = 0; path_node *node = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_KEY_L(L1, title); @@ -1809,7 +1819,7 @@ int ventoy_data_json_auto_memdisk(data_auto_memdisk *data, char *buf, int buflen int pos = 0; int valid = 0; path_node *node = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_ARY_BEGIN(); @@ -1817,10 +1827,10 @@ int ventoy_data_json_auto_memdisk(data_auto_memdisk *data, char *buf, int buflen { VTOY_JSON_FMT_OBJ_BEGIN(); - VTOY_JSON_FMT_STRN("path", node->path); + VTOY_JSON_FMT_STRN("path", node->path); valid = ventoy_check_fuzzy_path(node->path, 1); - VTOY_JSON_FMT_SINT("valid", valid); - + VTOY_JSON_FMT_SINT("valid", valid); + VTOY_JSON_FMT_OBJ_ENDEX(); } @@ -1839,7 +1849,7 @@ static int ventoy_api_get_auto_memdisk(struct mg_connection *conn, VTOY_JSON *js static int ventoy_api_save_auto_memdisk(struct mg_connection *conn, VTOY_JSON *json) { int ret; - + ret = ventoy_data_save_all(); ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); @@ -1854,7 +1864,7 @@ static int ventoy_api_auto_memdisk_add(struct mg_connection *conn, VTOY_JSON *js path_node *node = NULL; path_node *cur = NULL; data_auto_memdisk *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_auto_memdisk + index; @@ -1889,7 +1899,7 @@ static int ventoy_api_auto_memdisk_del(struct mg_connection *conn, VTOY_JSON *js path_node *last = NULL; path_node *node = NULL; data_auto_memdisk *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_auto_memdisk + index; @@ -1902,13 +1912,13 @@ static int ventoy_api_auto_memdisk_del(struct mg_connection *conn, VTOY_JSON *js } else { - vtoy_list_del(last, node, data->list, path); + vtoy_list_del(last, node, data->list, path); } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -1964,7 +1974,7 @@ int ventoy_data_save_image_list(data_image_list *data, const char *title, char * scnprintf(newtitle, sizeof(newtitle), "image_blacklist%s", title + prelen); } VTOY_JSON_FMT_KEY_L(L1, newtitle); - + VTOY_JSON_FMT_ARY_BEGIN_N(); for (node = data->list; node; node = node->next) @@ -1983,12 +1993,12 @@ int ventoy_data_json_image_list(data_image_list *data, char *buf, int buflen) int pos = 0; int valid = 0; path_node *node = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); - + VTOY_JSON_FMT_OBJ_BEGIN(); - VTOY_JSON_FMT_SINT("type", data->type); - + VTOY_JSON_FMT_SINT("type", data->type); + VTOY_JSON_FMT_KEY("list"); VTOY_JSON_FMT_ARY_BEGIN(); @@ -1996,16 +2006,16 @@ int ventoy_data_json_image_list(data_image_list *data, char *buf, int buflen) { VTOY_JSON_FMT_OBJ_BEGIN(); - VTOY_JSON_FMT_STRN("path", node->path); + VTOY_JSON_FMT_STRN("path", node->path); valid = ventoy_check_fuzzy_path(node->path, 1); - VTOY_JSON_FMT_SINT("valid", valid); - + VTOY_JSON_FMT_SINT("valid", valid); + VTOY_JSON_FMT_OBJ_ENDEX(); } VTOY_JSON_FMT_ARY_ENDEX(); VTOY_JSON_FMT_OBJ_END(); - + VTOY_JSON_FMT_END(pos); return pos; @@ -2022,7 +2032,7 @@ static int ventoy_api_save_image_list(struct mg_connection *conn, VTOY_JSON *jso int ret; int index = 0; data_image_list *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_image_list + index; @@ -2030,7 +2040,7 @@ static int ventoy_api_save_image_list(struct mg_connection *conn, VTOY_JSON *jso ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -2042,7 +2052,7 @@ static int ventoy_api_image_list_add(struct mg_connection *conn, VTOY_JSON *json path_node *node = NULL; path_node *cur = NULL; data_image_list *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_image_list + index; @@ -2077,7 +2087,7 @@ static int ventoy_api_image_list_del(struct mg_connection *conn, VTOY_JSON *json path_node *last = NULL; path_node *node = NULL; data_image_list *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_image_list + index; @@ -2090,13 +2100,13 @@ static int ventoy_api_image_list_del(struct mg_connection *conn, VTOY_JSON *json } else { - vtoy_list_del(last, node, data->list, path); + vtoy_list_del(last, node, data->list, path); } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -2113,12 +2123,12 @@ int ventoy_data_cmp_password(data_password *data1, data_password *data2) menu_password *list1 = NULL; menu_password *list2 = NULL; - if (strcmp(data1->bootpwd, data2->bootpwd) || - strcmp(data1->isopwd, data2->isopwd) || - strcmp(data1->wimpwd, data2->wimpwd) || - strcmp(data1->vhdpwd, data2->vhdpwd) || - strcmp(data1->imgpwd, data2->imgpwd) || - strcmp(data1->efipwd, data2->efipwd) || + if (strcmp(data1->bootpwd, data2->bootpwd) || + strcmp(data1->isopwd, data2->isopwd) || + strcmp(data1->wimpwd, data2->wimpwd) || + strcmp(data1->vhdpwd, data2->vhdpwd) || + strcmp(data1->imgpwd, data2->imgpwd) || + strcmp(data1->efipwd, data2->efipwd) || strcmp(data1->vtoypwd, data2->vtoypwd) ) { @@ -2133,14 +2143,14 @@ int ventoy_data_cmp_password(data_password *data1, data_password *data2) { list1 = data1->list; list2 = data2->list; - + while (list1 && list2) { if ((list1->type != list2->type) || strcmp(list1->path, list2->path)) { return 1; } - + list1 = list1->next; list2 = list2->next; } @@ -2165,7 +2175,7 @@ int ventoy_data_save_password(data_password *data, const char *title, char *buf, int pos = 0; menu_password *node = NULL; data_password *def = g_data_password + bios_max; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_KEY_L(L1, title); VTOY_JSON_FMT_OBJ_BEGIN_N(); @@ -2189,22 +2199,22 @@ int ventoy_data_save_password(data_password *data, const char *title, char *buf, if (node->type == 0) { - VTOY_JSON_FMT_STRN_PATH_LN(L4, "file", node->path); + VTOY_JSON_FMT_STRN_PATH_LN(L4, "file", node->path); } else { VTOY_JSON_FMT_STRN_PATH_LN(L4, "parent", node->path); } VTOY_JSON_FMT_STRN_LN(L4, "pwd", node->pwd); - + VTOY_JSON_FMT_OBJ_ENDEX_LN(L3); } VTOY_JSON_FMT_ARY_ENDEX_LN(L2); } - + VTOY_JSON_FMT_OBJ_ENDEX_LN(L1); - + VTOY_JSON_FMT_END(pos); return pos; @@ -2216,7 +2226,7 @@ int ventoy_data_json_password(data_password *data, char *buf, int buflen) int pos = 0; int valid = 0; menu_password *node = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_OBJ_BEGIN(); @@ -2246,10 +2256,10 @@ int ventoy_data_json_password(data_password *data, char *buf, int buflen) { valid = ventoy_is_directory_exist("%s%s", g_cur_dir, node->path); } - + VTOY_JSON_FMT_SINT("valid", valid); VTOY_JSON_FMT_STRN("pwd", node->pwd); - + VTOY_JSON_FMT_OBJ_ENDEX(); } @@ -2272,7 +2282,7 @@ static int ventoy_api_save_password(struct mg_connection *conn, VTOY_JSON *json) int ret; int index = 0; data_password *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_password + index; @@ -2286,7 +2296,7 @@ static int ventoy_api_save_password(struct mg_connection *conn, VTOY_JSON *json) ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -2300,7 +2310,7 @@ static int ventoy_api_password_add(struct mg_connection *conn, VTOY_JSON *json) menu_password *node = NULL; menu_password *cur = NULL; data_password *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_password + index; @@ -2322,14 +2332,14 @@ static int ventoy_api_password_add(struct mg_connection *conn, VTOY_JSON *json) node->type = type; scnprintf(node->path, sizeof(node->path), "%s", path); scnprintf(node->pwd, sizeof(node->pwd), "%s", pwd); - + vtoy_list_add(data->list, cur, node); } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -2341,7 +2351,7 @@ static int ventoy_api_password_del(struct mg_connection *conn, VTOY_JSON *json) menu_password *last = NULL; menu_password *node = NULL; data_password *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_password + index; @@ -2354,13 +2364,13 @@ static int ventoy_api_password_del(struct mg_connection *conn, VTOY_JSON *json) } else { - vtoy_list_del(last, node, data->list, path); + vtoy_list_del(last, node, data->list, path); } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -2385,18 +2395,18 @@ int ventoy_data_cmp_conf_replace(data_conf_replace *data1, data_conf_replace *da { list1 = data1->list; list2 = data2->list; - + while (list1 && list2) { if (list1->image != list2->image || - strcmp(list1->path, list2->path) || - strcmp(list1->org, list2->org) || + strcmp(list1->path, list2->path) || + strcmp(list1->org, list2->org) || strcmp(list1->new, list2->new) ) { return 1; } - + list1 = list1->next; list2 = list2->next; } @@ -2420,7 +2430,7 @@ int ventoy_data_save_conf_replace(data_conf_replace *data, const char *title, ch { int pos = 0; conf_replace_node *node = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_KEY_L(L1, title); @@ -2435,9 +2445,9 @@ int ventoy_data_save_conf_replace(data_conf_replace *data, const char *title, ch VTOY_JSON_FMT_STRN_PATH_LN(L3, "new", node->new); if (node->image) { - VTOY_JSON_FMT_SINT_LN(L3, "img", node->image); + VTOY_JSON_FMT_SINT_LN(L3, "img", node->image); } - + VTOY_JSON_FMT_OBJ_ENDEX_LN(L2); } @@ -2452,7 +2462,7 @@ int ventoy_data_json_conf_replace(data_conf_replace *data, char *buf, int buflen { int pos = 0; conf_replace_node *node = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_ARY_BEGIN(); @@ -2466,7 +2476,7 @@ int ventoy_data_json_conf_replace(data_conf_replace *data, char *buf, int buflen VTOY_JSON_FMT_STRN("new", node->new); VTOY_JSON_FMT_SINT("new_valid", ventoy_is_file_exist("%s%s", g_cur_dir, node->new)); VTOY_JSON_FMT_SINT("img", node->image); - + VTOY_JSON_FMT_OBJ_ENDEX(); } @@ -2487,7 +2497,7 @@ static int ventoy_api_save_conf_replace(struct mg_connection *conn, VTOY_JSON *j int ret; ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -2502,9 +2512,9 @@ static int ventoy_api_conf_replace_add(struct mg_connection *conn, VTOY_JSON *js conf_replace_node *node = NULL; conf_replace_node *cur = NULL; data_conf_replace *data = NULL; - + vtoy_json_get_int(json, "img", &image); - + vtoy_json_get_int(json, "index", &index); data = g_data_conf_replace + index; @@ -2520,14 +2530,14 @@ static int ventoy_api_conf_replace_add(struct mg_connection *conn, VTOY_JSON *js scnprintf(node->path, sizeof(node->path), "%s", path); scnprintf(node->org, sizeof(node->org), "%s", org); scnprintf(node->new, sizeof(node->new), "%s", new); - + vtoy_list_add(data->list, cur, node); } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -2539,7 +2549,7 @@ static int ventoy_api_conf_replace_del(struct mg_connection *conn, VTOY_JSON *js conf_replace_node *last = NULL; conf_replace_node *node = NULL; data_conf_replace *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_conf_replace + index; @@ -2552,13 +2562,13 @@ static int ventoy_api_conf_replace_del(struct mg_connection *conn, VTOY_JSON *js } else { - vtoy_list_del(last, node, data->list, path); + vtoy_list_del(last, node, data->list, path); } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -2584,7 +2594,7 @@ int ventoy_data_cmp_dud(data_dud *data1, data_dud *data2) { list1 = data1->list; list2 = data2->list; - + while (list1 && list2) { if (strcmp(list1->path, list2->path)) @@ -2617,7 +2627,7 @@ int ventoy_data_save_dud(data_dud *data, const char *title, char *buf, int bufle int pos = 0; dud_node *node = NULL; path_node *pathnode = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_KEY_L(L1, title); @@ -2626,7 +2636,7 @@ int ventoy_data_save_dud(data_dud *data, const char *title, char *buf, int bufle for (node = data->list; node; node = node->next) { VTOY_JSON_FMT_OBJ_BEGIN_LN(L2); - VTOY_JSON_FMT_STRN_PATH_LN(L3, "image", node->path); + VTOY_JSON_FMT_STRN_PATH_LN(L3, "image", node->path); VTOY_JSON_FMT_KEY_L(L3, "dud"); VTOY_JSON_FMT_ARY_BEGIN_N(); @@ -2634,8 +2644,8 @@ int ventoy_data_save_dud(data_dud *data, const char *title, char *buf, int bufle { VTOY_JSON_FMT_ITEM_PATH_LN(L4, pathnode->path); } - VTOY_JSON_FMT_ARY_ENDEX_LN(L3); - + VTOY_JSON_FMT_ARY_ENDEX_LN(L3); + VTOY_JSON_FMT_OBJ_ENDEX_LN(L2); } @@ -2652,7 +2662,7 @@ int ventoy_data_json_dud(data_dud *data, char *buf, int buflen) int valid = 0; dud_node *node = NULL; path_node *pathnode = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_ARY_BEGIN(); @@ -2663,7 +2673,7 @@ int ventoy_data_json_dud(data_dud *data, char *buf, int buflen) VTOY_JSON_FMT_STRN("path", node->path); valid = ventoy_check_fuzzy_path(node->path, 1); VTOY_JSON_FMT_SINT("valid", valid); - + VTOY_JSON_FMT_KEY("list"); VTOY_JSON_FMT_ARY_BEGIN(); @@ -2676,9 +2686,9 @@ int ventoy_data_json_dud(data_dud *data, char *buf, int buflen) VTOY_JSON_FMT_SINT("valid", valid); VTOY_JSON_FMT_OBJ_ENDEX(); } - VTOY_JSON_FMT_ARY_ENDEX(); + VTOY_JSON_FMT_ARY_ENDEX(); + - VTOY_JSON_FMT_OBJ_ENDEX(); } @@ -2699,7 +2709,7 @@ static int ventoy_api_save_dud(struct mg_connection *conn, VTOY_JSON *json) int ret; ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -2713,7 +2723,7 @@ static int ventoy_api_dud_add(struct mg_connection *conn, VTOY_JSON *json) dud_node *cur = NULL; data_dud *data = NULL; VTOY_JSON *array = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_dud + index; @@ -2726,20 +2736,20 @@ static int ventoy_api_dud_add(struct mg_connection *conn, VTOY_JSON *json) ventoy_json_result(conn, VTOY_JSON_DUPLICATE); return 0; } - + node = zalloc(sizeof(dud_node)); if (node) { scnprintf(node->path, sizeof(node->path), "%s", path); node->list = ventoy_path_node_add_array(array); - + vtoy_list_add(data->list, cur, node); } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -2752,7 +2762,7 @@ static int ventoy_api_dud_del(struct mg_connection *conn, VTOY_JSON *json) dud_node *last = NULL; dud_node *node = NULL; data_dud *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_dud + index; @@ -2777,7 +2787,7 @@ static int ventoy_api_dud_del(struct mg_connection *conn, VTOY_JSON *json) ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -2792,7 +2802,7 @@ static int ventoy_api_dud_add_inner(struct mg_connection *conn, VTOY_JSON *json) path_node *pnode = NULL; dud_node *node = NULL; data_dud *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_dud + index; @@ -2810,7 +2820,7 @@ static int ventoy_api_dud_add_inner(struct mg_connection *conn, VTOY_JSON *json) scnprintf(pnode->path, sizeof(pnode->path), "%s", path); vtoy_list_add(node->list, pcur, pnode); } - + break; } } @@ -2818,7 +2828,7 @@ static int ventoy_api_dud_add_inner(struct mg_connection *conn, VTOY_JSON *json) ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -2832,7 +2842,7 @@ static int ventoy_api_dud_del_inner(struct mg_connection *conn, VTOY_JSON *json) path_node *pnode = NULL; dud_node *node = NULL; data_dud *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_dud + index; @@ -2852,7 +2862,7 @@ static int ventoy_api_dud_del_inner(struct mg_connection *conn, VTOY_JSON *json) ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -2878,7 +2888,7 @@ int ventoy_data_cmp_auto_install(data_auto_install *data1, data_auto_install *da { list1 = data1->list; list2 = data2->list; - + while (list1 && list2) { if (list1->timeout != list2->timeout || @@ -2913,7 +2923,7 @@ int ventoy_data_save_auto_install(data_auto_install *data, const char *title, ch int pos = 0; auto_install_node *node = NULL; path_node *pathnode = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_KEY_L(L1, title); @@ -2924,14 +2934,14 @@ int ventoy_data_save_auto_install(data_auto_install *data, const char *title, ch VTOY_JSON_FMT_OBJ_BEGIN_LN(L2); if (node->type == 0) { - VTOY_JSON_FMT_STRN_PATH_LN(L3, "image", node->path); + VTOY_JSON_FMT_STRN_PATH_LN(L3, "image", node->path); } else { - VTOY_JSON_FMT_STRN_PATH_LN(L3, "parent", node->path); + VTOY_JSON_FMT_STRN_PATH_LN(L3, "parent", node->path); } - + VTOY_JSON_FMT_KEY_L(L3, "template"); VTOY_JSON_FMT_ARY_BEGIN_N(); for (pathnode = node->list; pathnode; pathnode = pathnode->next) @@ -2947,7 +2957,7 @@ int ventoy_data_save_auto_install(data_auto_install *data, const char *title, ch if (node->autoselen) { - VTOY_JSON_FMT_SINT_LN(L3, "autosel", node->autosel); + VTOY_JSON_FMT_SINT_LN(L3, "autosel", node->autosel); } VTOY_JSON_FMT_OBJ_ENDEX_LN(L2); @@ -2966,7 +2976,7 @@ int ventoy_data_json_auto_install(data_auto_install *data, char *buf, int buflen int valid = 0; auto_install_node *node = NULL; path_node *pathnode = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_ARY_BEGIN(); @@ -2978,7 +2988,7 @@ int ventoy_data_json_auto_install(data_auto_install *data, char *buf, int buflen if (node->type == 0) { - valid = ventoy_check_fuzzy_path(node->path, 1); + valid = ventoy_check_fuzzy_path(node->path, 1); } else { @@ -2986,10 +2996,10 @@ int ventoy_data_json_auto_install(data_auto_install *data, char *buf, int buflen } VTOY_JSON_FMT_SINT("valid", valid); VTOY_JSON_FMT_SINT("type", node->type); - + VTOY_JSON_FMT_BOOL("timeouten", node->timeouten); VTOY_JSON_FMT_BOOL("autoselen", node->autoselen); - + VTOY_JSON_FMT_SINT("autosel", node->autosel); VTOY_JSON_FMT_SINT("timeout", node->timeout); @@ -3004,9 +3014,9 @@ int ventoy_data_json_auto_install(data_auto_install *data, char *buf, int buflen VTOY_JSON_FMT_SINT("valid", valid); VTOY_JSON_FMT_OBJ_ENDEX(); } - VTOY_JSON_FMT_ARY_ENDEX(); + VTOY_JSON_FMT_ARY_ENDEX(); + - VTOY_JSON_FMT_OBJ_ENDEX(); } @@ -3032,13 +3042,13 @@ static int ventoy_api_save_auto_install(struct mg_connection *conn, VTOY_JSON *j uint8_t autoselen = 0; auto_install_node *node = NULL; data_auto_install *data = NULL; - + vtoy_json_get_int(json, "index", &index); vtoy_json_get_int(json, "id", &id); vtoy_json_get_bool(json, "timeouten", &timeouten); vtoy_json_get_bool(json, "autoselen", &autoselen); - + data = g_data_auto_install + index; if (id >= 0) @@ -3058,7 +3068,7 @@ static int ventoy_api_save_auto_install(struct mg_connection *conn, VTOY_JSON *j ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -3073,7 +3083,7 @@ static int ventoy_api_auto_install_add(struct mg_connection *conn, VTOY_JSON *js auto_install_node *cur = NULL; data_auto_install *data = NULL; VTOY_JSON *array = NULL; - + vtoy_json_get_int(json, "type", &type); vtoy_json_get_int(json, "index", &index); data = g_data_auto_install + index; @@ -3086,8 +3096,8 @@ static int ventoy_api_auto_install_add(struct mg_connection *conn, VTOY_JSON *js { ventoy_json_result(conn, VTOY_JSON_DUPLICATE); return 0; - } - + } + node = zalloc(sizeof(auto_install_node)); if (node) { @@ -3098,14 +3108,14 @@ static int ventoy_api_auto_install_add(struct mg_connection *conn, VTOY_JSON *js node->timeout = 0; scnprintf(node->path, sizeof(node->path), "%s", path); node->list = ventoy_path_node_add_array(array); - + vtoy_list_add(data->list, cur, node); } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -3118,7 +3128,7 @@ static int ventoy_api_auto_install_del(struct mg_connection *conn, VTOY_JSON *js auto_install_node *next = NULL; auto_install_node *node = NULL; data_auto_install *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_auto_install + index; @@ -3137,13 +3147,13 @@ static int ventoy_api_auto_install_del(struct mg_connection *conn, VTOY_JSON *js } else { - vtoy_list_del_ex(last, node, data->list, path, ventoy_free_path_node_list); + vtoy_list_del_ex(last, node, data->list, path, ventoy_free_path_node_list); } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -3157,7 +3167,7 @@ static int ventoy_api_auto_install_add_inner(struct mg_connection *conn, VTOY_JS path_node *pnode = NULL; auto_install_node *node = NULL; data_auto_install *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_auto_install + index; @@ -3175,7 +3185,7 @@ static int ventoy_api_auto_install_add_inner(struct mg_connection *conn, VTOY_JS scnprintf(pnode->path, sizeof(pnode->path), "%s", path); vtoy_list_add(node->list, pcur, pnode); } - + break; } } @@ -3183,7 +3193,7 @@ static int ventoy_api_auto_install_add_inner(struct mg_connection *conn, VTOY_JS ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -3197,7 +3207,7 @@ static int ventoy_api_auto_install_del_inner(struct mg_connection *conn, VTOY_JS path_node *pnode = NULL; auto_install_node *node = NULL; data_auto_install *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_auto_install + index; @@ -3217,7 +3227,7 @@ static int ventoy_api_auto_install_del_inner(struct mg_connection *conn, VTOY_JS ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -3244,7 +3254,7 @@ int ventoy_data_cmp_persistence(data_persistence *data1, data_persistence *data2 { list1 = data1->list; list2 = data2->list; - + while (list1 && list2) { if (list1->timeout != list2->timeout || @@ -3279,7 +3289,7 @@ int ventoy_data_save_persistence(data_persistence *data, const char *title, char int pos = 0; persistence_node *node = NULL; path_node *pathnode = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_KEY_L(L1, title); @@ -3288,7 +3298,7 @@ int ventoy_data_save_persistence(data_persistence *data, const char *title, char for (node = data->list; node; node = node->next) { VTOY_JSON_FMT_OBJ_BEGIN_LN(L2); - VTOY_JSON_FMT_STRN_PATH_LN(L3, "image", node->path); + VTOY_JSON_FMT_STRN_PATH_LN(L3, "image", node->path); VTOY_JSON_FMT_KEY_L(L3, "backend"); VTOY_JSON_FMT_ARY_BEGIN_N(); for (pathnode = node->list; pathnode; pathnode = pathnode->next) @@ -3304,7 +3314,7 @@ int ventoy_data_save_persistence(data_persistence *data, const char *title, char if (node->autoselen) { - VTOY_JSON_FMT_SINT_LN(L3, "autosel", node->autosel); + VTOY_JSON_FMT_SINT_LN(L3, "autosel", node->autosel); } VTOY_JSON_FMT_OBJ_ENDEX_LN(L2); @@ -3323,7 +3333,7 @@ int ventoy_data_json_persistence(data_persistence *data, char *buf, int buflen) int valid = 0; persistence_node *node = NULL; path_node *pathnode = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_ARY_BEGIN(); @@ -3333,13 +3343,13 @@ int ventoy_data_json_persistence(data_persistence *data, char *buf, int buflen) VTOY_JSON_FMT_STRN("path", node->path); - valid = ventoy_check_fuzzy_path(node->path, 1); + valid = ventoy_check_fuzzy_path(node->path, 1); VTOY_JSON_FMT_SINT("valid", valid); VTOY_JSON_FMT_SINT("type", node->type); - + VTOY_JSON_FMT_BOOL("timeouten", node->timeouten); VTOY_JSON_FMT_BOOL("autoselen", node->autoselen); - + VTOY_JSON_FMT_SINT("autosel", node->autosel); VTOY_JSON_FMT_SINT("timeout", node->timeout); @@ -3354,9 +3364,9 @@ int ventoy_data_json_persistence(data_persistence *data, char *buf, int buflen) VTOY_JSON_FMT_SINT("valid", valid); VTOY_JSON_FMT_OBJ_ENDEX(); } - VTOY_JSON_FMT_ARY_ENDEX(); + VTOY_JSON_FMT_ARY_ENDEX(); + - VTOY_JSON_FMT_OBJ_ENDEX(); } @@ -3382,13 +3392,13 @@ static int ventoy_api_save_persistence(struct mg_connection *conn, VTOY_JSON *js uint8_t autoselen = 0; persistence_node *node = NULL; data_persistence *data = NULL; - + vtoy_json_get_int(json, "index", &index); vtoy_json_get_int(json, "id", &id); vtoy_json_get_bool(json, "timeouten", &timeouten); vtoy_json_get_bool(json, "autoselen", &autoselen); - + data = g_data_persistence + index; if (id >= 0) @@ -3408,7 +3418,7 @@ static int ventoy_api_save_persistence(struct mg_connection *conn, VTOY_JSON *js ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -3422,7 +3432,7 @@ static int ventoy_api_persistence_add(struct mg_connection *conn, VTOY_JSON *jso persistence_node *cur = NULL; data_persistence *data = NULL; VTOY_JSON *array = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_persistence + index; @@ -3435,7 +3445,7 @@ static int ventoy_api_persistence_add(struct mg_connection *conn, VTOY_JSON *jso ventoy_json_result(conn, VTOY_JSON_DUPLICATE); return 0; } - + node = zalloc(sizeof(persistence_node)); if (node) { @@ -3445,14 +3455,14 @@ static int ventoy_api_persistence_add(struct mg_connection *conn, VTOY_JSON *jso node->timeout = 0; scnprintf(node->path, sizeof(node->path), "%s", path); node->list = ventoy_path_node_add_array(array); - + vtoy_list_add(data->list, cur, node); } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -3465,7 +3475,7 @@ static int ventoy_api_persistence_del(struct mg_connection *conn, VTOY_JSON *jso persistence_node *next = NULL; persistence_node *node = NULL; data_persistence *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_persistence + index; @@ -3484,13 +3494,13 @@ static int ventoy_api_persistence_del(struct mg_connection *conn, VTOY_JSON *jso } else { - vtoy_list_del_ex(last, node, data->list, path, ventoy_free_path_node_list); - } + vtoy_list_del_ex(last, node, data->list, path, ventoy_free_path_node_list); + } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -3504,7 +3514,7 @@ static int ventoy_api_persistence_add_inner(struct mg_connection *conn, VTOY_JSO path_node *pnode = NULL; persistence_node *node = NULL; data_persistence *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_persistence + index; @@ -3522,7 +3532,7 @@ static int ventoy_api_persistence_add_inner(struct mg_connection *conn, VTOY_JSO scnprintf(pnode->path, sizeof(pnode->path), "%s", path); vtoy_list_add(node->list, pcur, pnode); } - + break; } } @@ -3530,7 +3540,7 @@ static int ventoy_api_persistence_add_inner(struct mg_connection *conn, VTOY_JSO ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -3544,7 +3554,7 @@ static int ventoy_api_persistence_del_inner(struct mg_connection *conn, VTOY_JSO path_node *pnode = NULL; persistence_node *node = NULL; data_persistence *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_persistence + index; @@ -3564,7 +3574,7 @@ static int ventoy_api_persistence_del_inner(struct mg_connection *conn, VTOY_JSO ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -3590,16 +3600,16 @@ int ventoy_data_cmp_injection(data_injection *data1, data_injection *data2) { list1 = data1->list; list2 = data2->list; - + while (list1 && list2) { if ((list1->type != list2->type) || - strcmp(list1->path, list2->path) || + strcmp(list1->path, list2->path) || strcmp(list1->archive, list2->archive)) { return 1; } - + list1 = list1->next; list2 = list2->next; } @@ -3623,7 +3633,7 @@ int ventoy_data_save_injection(data_injection *data, const char *title, char *bu { int pos = 0; injection_node *node = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_KEY_L(L1, title); @@ -3635,14 +3645,14 @@ int ventoy_data_save_injection(data_injection *data, const char *title, char *bu if (node->type == 0) { - VTOY_JSON_FMT_STRN_PATH_LN(L3, "image", node->path); + VTOY_JSON_FMT_STRN_PATH_LN(L3, "image", node->path); } else { VTOY_JSON_FMT_STRN_PATH_LN(L3, "parent", node->path); } VTOY_JSON_FMT_STRN_PATH_LN(L3, "archive", node->archive); - + VTOY_JSON_FMT_OBJ_ENDEX_LN(L2); } @@ -3658,7 +3668,7 @@ int ventoy_data_json_injection(data_injection *data, char *buf, int buflen) int pos = 0; int valid = 0; injection_node *node = NULL; - + VTOY_JSON_FMT_BEGIN(pos, buf, buflen); VTOY_JSON_FMT_ARY_BEGIN(); @@ -3667,7 +3677,7 @@ int ventoy_data_json_injection(data_injection *data, char *buf, int buflen) VTOY_JSON_FMT_OBJ_BEGIN(); VTOY_JSON_FMT_UINT("type", node->type); - VTOY_JSON_FMT_STRN("path", node->path); + VTOY_JSON_FMT_STRN("path", node->path); if (node->type == 0) { @@ -3678,12 +3688,12 @@ int ventoy_data_json_injection(data_injection *data, char *buf, int buflen) valid = ventoy_is_directory_exist("%s%s", g_cur_dir, node->path); } VTOY_JSON_FMT_SINT("valid", valid); - + VTOY_JSON_FMT_STRN("archive", node->archive); valid = ventoy_is_file_exist("%s%s", g_cur_dir, node->archive); VTOY_JSON_FMT_SINT("archive_valid", valid); - + VTOY_JSON_FMT_OBJ_ENDEX(); } @@ -3705,7 +3715,7 @@ static int ventoy_api_save_injection(struct mg_connection *conn, VTOY_JSON *json int ret; ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -3719,7 +3729,7 @@ static int ventoy_api_injection_add(struct mg_connection *conn, VTOY_JSON *json) injection_node *node = NULL; injection_node *cur = NULL; data_injection *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_injection + index; @@ -3734,22 +3744,22 @@ static int ventoy_api_injection_add(struct mg_connection *conn, VTOY_JSON *json) ventoy_json_result(conn, VTOY_JSON_DUPLICATE); return 0; } - + node = zalloc(sizeof(injection_node)); if (node) { node->type = type; - + scnprintf(node->path, sizeof(node->path), "%s", path); scnprintf(node->archive, sizeof(node->archive), "%s", archive); - + vtoy_list_add(data->list, cur, node); } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -3761,7 +3771,7 @@ static int ventoy_api_injection_del(struct mg_connection *conn, VTOY_JSON *json) injection_node *last = NULL; injection_node *node = NULL; data_injection *data = NULL; - + vtoy_json_get_int(json, "index", &index); data = g_data_injection + index; @@ -3774,13 +3784,13 @@ static int ventoy_api_injection_del(struct mg_connection *conn, VTOY_JSON *json) } else { - vtoy_list_del(last, node, data->list, path); + vtoy_list_del(last, node, data->list, path); } } ret = ventoy_data_save_all(); - ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); + ventoy_json_result(conn, ret == 0 ? VTOY_JSON_SUCCESS_RET : VTOY_JSON_FAILED_RET); return 0; } @@ -3795,14 +3805,14 @@ static int ventoy_api_preview_json(struct mg_connection *conn, VTOY_JSON *json) int utf16enclen = 0; char *encodebuf = NULL; unsigned short *utf16buf = NULL; - + (void)json; /* We can not use json directly, because it will be formated in the JS. */ len = ventoy_data_real_save_all(0); - utf16buf = (unsigned short *)malloc(2 * len + 16); + utf16buf = (unsigned short *)malloc(2 * len + 16); if (!utf16buf) { goto json; @@ -3853,7 +3863,7 @@ int ventoy_data_real_save_all(int apilock) if (apilock) { - pthread_mutex_lock(&g_api_mutex); + pthread_mutex_lock(&g_api_mutex); } ssprintf(pos, JSON_SAVE_BUFFER, JSON_BUF_MAX, "{\n"); @@ -3871,7 +3881,7 @@ int ventoy_data_real_save_all(int apilock) ventoy_save_plug(image_list); ventoy_save_plug(auto_memdisk); ventoy_save_plug(dud); - + if (JSON_SAVE_BUFFER[pos - 1] == '\n' && JSON_SAVE_BUFFER[pos - 2] == ',') { JSON_SAVE_BUFFER[pos - 2] = '\n'; @@ -3881,7 +3891,7 @@ int ventoy_data_real_save_all(int apilock) if (apilock) { - pthread_mutex_unlock(&g_api_mutex); + pthread_mutex_unlock(&g_api_mutex); } return pos; @@ -3896,11 +3906,11 @@ int ventoy_http_writeback(void) ventoy_get_json_path(filename, NULL); pos = ventoy_data_real_save_all(1); - + #ifdef VENTOY_SIM printf("%s", JSON_SAVE_BUFFER); #endif - + ret = ventoy_write_buf_to_file(filename, JSON_SAVE_BUFFER, pos); if (ret) { @@ -3912,88 +3922,88 @@ int ventoy_http_writeback(void) } -static JSON_CB g_ventoy_json_cb[] = +static JSON_CB g_ventoy_json_cb[] = { - { "sysinfo", ventoy_api_sysinfo }, - { "handshake", ventoy_api_handshake }, - { "check_path", ventoy_api_check_exist }, - { "check_path2", ventoy_api_check_exist2 }, + { "sysinfo", ventoy_api_sysinfo }, + { "handshake", ventoy_api_handshake }, + { "check_path", ventoy_api_check_exist }, + { "check_path2", ventoy_api_check_exist2 }, { "check_fuzzy", ventoy_api_check_fuzzy }, - - { "device_info", ventoy_api_device_info }, - - { "get_control", ventoy_api_get_control }, - { "save_control", ventoy_api_save_control }, - - { "get_theme", ventoy_api_get_theme }, - { "save_theme", ventoy_api_save_theme }, - { "theme_add_file", ventoy_api_theme_add_file }, - { "theme_del_file", ventoy_api_theme_del_file }, - { "theme_add_font", ventoy_api_theme_add_font }, + + { "device_info", ventoy_api_device_info }, + + { "get_control", ventoy_api_get_control }, + { "save_control", ventoy_api_save_control }, + + { "get_theme", ventoy_api_get_theme }, + { "save_theme", ventoy_api_save_theme }, + { "theme_add_file", ventoy_api_theme_add_file }, + { "theme_del_file", ventoy_api_theme_del_file }, + { "theme_add_font", ventoy_api_theme_add_font }, { "theme_del_font", ventoy_api_theme_del_font }, - + { "get_alias", ventoy_api_get_alias }, - { "save_alias", ventoy_api_save_alias }, + { "save_alias", ventoy_api_save_alias }, { "alias_add", ventoy_api_alias_add }, { "alias_del", ventoy_api_alias_del }, - + { "get_tip", ventoy_api_get_tip }, - { "save_tip", ventoy_api_save_tip }, + { "save_tip", ventoy_api_save_tip }, { "tip_add", ventoy_api_tip_add }, { "tip_del", ventoy_api_tip_del }, - + { "get_class", ventoy_api_get_class }, - { "save_class", ventoy_api_save_class }, + { "save_class", ventoy_api_save_class }, { "class_add", ventoy_api_class_add }, { "class_del", ventoy_api_class_del }, - + { "get_auto_memdisk", ventoy_api_get_auto_memdisk }, - { "save_auto_memdisk", ventoy_api_save_auto_memdisk }, + { "save_auto_memdisk", ventoy_api_save_auto_memdisk }, { "auto_memdisk_add", ventoy_api_auto_memdisk_add }, { "auto_memdisk_del", ventoy_api_auto_memdisk_del }, - + { "get_image_list", ventoy_api_get_image_list }, { "save_image_list", ventoy_api_save_image_list }, { "image_list_add", ventoy_api_image_list_add }, { "image_list_del", ventoy_api_image_list_del }, { "get_conf_replace", ventoy_api_get_conf_replace }, - { "save_conf_replace", ventoy_api_save_conf_replace }, + { "save_conf_replace", ventoy_api_save_conf_replace }, { "conf_replace_add", ventoy_api_conf_replace_add }, { "conf_replace_del", ventoy_api_conf_replace_del }, - + { "get_dud", ventoy_api_get_dud }, - { "save_dud", ventoy_api_save_dud }, + { "save_dud", ventoy_api_save_dud }, { "dud_add", ventoy_api_dud_add }, { "dud_del", ventoy_api_dud_del }, { "dud_add_inner", ventoy_api_dud_add_inner }, { "dud_del_inner", ventoy_api_dud_del_inner }, - + { "get_auto_install", ventoy_api_get_auto_install }, - { "save_auto_install", ventoy_api_save_auto_install }, + { "save_auto_install", ventoy_api_save_auto_install }, { "auto_install_add", ventoy_api_auto_install_add }, { "auto_install_del", ventoy_api_auto_install_del }, { "auto_install_add_inner", ventoy_api_auto_install_add_inner }, { "auto_install_del_inner", ventoy_api_auto_install_del_inner }, - + { "get_persistence", ventoy_api_get_persistence }, - { "save_persistence", ventoy_api_save_persistence }, + { "save_persistence", ventoy_api_save_persistence }, { "persistence_add", ventoy_api_persistence_add }, { "persistence_del", ventoy_api_persistence_del }, { "persistence_add_inner", ventoy_api_persistence_add_inner }, { "persistence_del_inner", ventoy_api_persistence_del_inner }, - + { "get_password", ventoy_api_get_password }, - { "save_password", ventoy_api_save_password }, + { "save_password", ventoy_api_save_password }, { "password_add", ventoy_api_password_add }, { "password_del", ventoy_api_password_del }, - + { "get_injection", ventoy_api_get_injection }, - { "save_injection", ventoy_api_save_injection }, + { "save_injection", ventoy_api_save_injection }, { "injection_add", ventoy_api_injection_add }, { "injection_del", ventoy_api_injection_del }, { "preview_json", ventoy_api_preview_json }, - + }; static int ventoy_json_handler(struct mg_connection *conn, VTOY_JSON *json, char *jsonstr) @@ -4034,8 +4044,8 @@ static int ventoy_request_handler(struct mg_connection *conn) char *post_data_buf = NULL; const struct mg_request_info *ri = NULL; char stack_buf[512]; - - ri = mg_get_request_info(conn); + + ri = mg_get_request_info(conn); if (strcmp(ri->uri, "/vtoy/json") == 0) { @@ -4049,7 +4059,7 @@ static int ventoy_request_handler(struct mg_connection *conn) post_data_buf = stack_buf; post_buf_len = sizeof(stack_buf); } - + post_data_len = mg_read(conn, post_data_buf, post_buf_len); post_data_buf[post_data_len] = 0; @@ -4089,7 +4099,7 @@ const char *ventoy_web_openfile(const struct mg_connection *conn, const char *pa { return NULL; } - + node = ventoy_tar_find_file(path); if (node) { @@ -4122,7 +4132,7 @@ static int ventoy_parse_control(VTOY_JSON *json, void *p) if (node->enDataType == JSON_TYPE_OBJECT) { child = node->pstChild; - + if (child->enDataType != JSON_TYPE_STRING) { continue; @@ -4164,6 +4174,14 @@ static int ventoy_parse_control(VTOY_JSON *json, void *p) { CONTROL_PARSE_INT_DEF_0(child, data->sort_casesensitive); } + else if (strcmp(child->pcName, "VTOY_WIN_UEFI_RES_LOCK") == 0) + { + CONTROL_PARSE_INT_DEF_3(child, data->uefi_res_lock); + } + else if (strcmp(child->pcName, "VTOY_SECURE_BOOT_POLICY") == 0) + { + CONTROL_PARSE_INT_DEF_0(child, data->uefi_sb_policy); + } else if (strcmp(child->pcName, "VTOY_MAX_SEARCH_LEVEL") == 0) { if (strcmp(child->unData.pcStrVal, "max") == 0) @@ -4241,7 +4259,7 @@ static int ventoy_parse_control(VTOY_JSON *json, void *p) { CONTROL_PARSE_INT_DEF_0(child, data->filter_vtoy); } - + } } @@ -4267,9 +4285,9 @@ static int ventoy_parse_theme(VTOY_JSON *json, void *p) vtoy_json_get_string(child, "ventoy_left", sizeof(data->ventoy_left), data->ventoy_left); vtoy_json_get_string(child, "ventoy_top", sizeof(data->ventoy_top), data->ventoy_top); vtoy_json_get_string(child, "ventoy_color", sizeof(data->ventoy_color), data->ventoy_color); - - vtoy_json_get_int(child, "default_file", &(data->default_file)); - vtoy_json_get_int(child, "resolution_fit", &(data->resolution_fit)); + + vtoy_json_get_int(child, "default_file", &(data->default_file)); + vtoy_json_get_int(child, "resolution_fit", &(data->resolution_fit)); vtoy_json_get_string(child, "gfxmode", sizeof(data->gfxmode), data->gfxmode); vtoy_json_get_string(child, "serial_param", sizeof(data->serial_param), data->serial_param); @@ -4334,7 +4352,7 @@ static int ventoy_parse_theme(VTOY_JSON *json, void *p) } } - + node = vtoy_json_find_item(child, JSON_TYPE_ARRAY, "fonts"); if (node) { @@ -4401,7 +4419,7 @@ static int ventoy_parse_menu_alias(VTOY_JSON *json, void *p) pnode->type = type; strlcpy(pnode->path, path); strlcpy(pnode->alias, alias); - + if (data->list) { tail->next = pnode; @@ -4413,7 +4431,7 @@ static int ventoy_parse_menu_alias(VTOY_JSON *json, void *p) } } } - } + } return 0; } @@ -4468,7 +4486,7 @@ static int ventoy_parse_menu_tip(VTOY_JSON *json, void *p) pnode->type = type; strlcpy(pnode->path, path); strlcpy(pnode->tip, tip); - + if (data->list) { tail->next = pnode; @@ -4480,7 +4498,7 @@ static int ventoy_parse_menu_tip(VTOY_JSON *json, void *p) } } } - } + } return 0; } @@ -4528,7 +4546,7 @@ static int ventoy_parse_menu_class(VTOY_JSON *json, void *p) pnode->type = type; strlcpy(pnode->path, path); strlcpy(pnode->class, class); - + if (data->list) { tail->next = pnode; @@ -4540,7 +4558,7 @@ static int ventoy_parse_menu_class(VTOY_JSON *json, void *p) } } } - } + } return 0; } @@ -4586,7 +4604,7 @@ static int ventoy_parse_auto_install(VTOY_JSON *json, void *p) { continue; } - + file = vtoy_json_get_string_ex(node->pstChild, "template"); if (file) { @@ -4674,7 +4692,7 @@ static int ventoy_parse_auto_install(VTOY_JSON *json, void *p) else { pnode->list = pathtail = pathnode; - } + } } } @@ -4738,7 +4756,7 @@ static int ventoy_parse_persistence(VTOY_JSON *json, void *p) { continue; } - + file = vtoy_json_get_string_ex(node->pstChild, "backend"); if (file) { @@ -4826,7 +4844,7 @@ static int ventoy_parse_persistence(VTOY_JSON *json, void *p) else { pnode->list = pathtail = pathnode; - } + } } } @@ -4894,7 +4912,7 @@ static int ventoy_parse_injection(VTOY_JSON *json, void *p) pnode->type = type; strlcpy(pnode->path, path); strlcpy(pnode->archive, archive); - + if (data->list) { tail->next = pnode; @@ -4906,7 +4924,7 @@ static int ventoy_parse_injection(VTOY_JSON *json, void *p) } } } - } + } return 0; } @@ -4950,9 +4968,9 @@ static int ventoy_parse_conf_replace(VTOY_JSON *json, void *p) strlcpy(pnode->new, new); if (img == 1) { - pnode->image = img; + pnode->image = img; } - + if (data->list) { tail->next = pnode; @@ -4964,7 +4982,7 @@ static int ventoy_parse_conf_replace(VTOY_JSON *json, void *p) } } } - } + } return 0; } @@ -5007,8 +5025,8 @@ static int ventoy_parse_password(VTOY_JSON *json, void *p) if (efipwd) strlcpy(data->efipwd, efipwd); if (vhdpwd) strlcpy(data->vhdpwd, vhdpwd); if (vtoypwd) strlcpy(data->vtoypwd, vtoypwd); - - + + menupwd = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "menupwd"); if (!menupwd) { @@ -5039,7 +5057,7 @@ static int ventoy_parse_password(VTOY_JSON *json, void *p) pnode->type = type; strlcpy(pnode->path, path); strlcpy(pnode->pwd, pwd); - + if (data->list) { tail->next = pnode; @@ -5051,7 +5069,7 @@ static int ventoy_parse_password(VTOY_JSON *json, void *p) } } } - } + } return 0; } @@ -5168,7 +5186,7 @@ static int ventoy_parse_dud(VTOY_JSON *json, void *p) { continue; } - + file = vtoy_json_get_string_ex(node->pstChild, "dud"); if (file) { @@ -5237,7 +5255,7 @@ static int ventoy_parse_dud(VTOY_JSON *json, void *p) else { pnode->list = pathtail = pathnode; - } + } } } @@ -5306,7 +5324,7 @@ static int ventoy_load_old_json(const char *filename) free(buffer); return 1; } - + if (vtoy_json_parse_ex(json, buffer + offset, buflen - offset) == JSON_SUCCESS) { vlog("parse ventoy.json success\n"); @@ -5343,7 +5361,7 @@ static int ventoy_load_old_json(const char *filename) } else { - vlog("ventoy.json has syntax error.\n"); + vlog("ventoy.json has syntax error.\n"); g_sysinfo.syntax_error = 1; ret = 1; } @@ -5364,7 +5382,7 @@ int ventoy_http_start(const char *ip, const char *port) char filename[128]; char backupname[128]; struct mg_callbacks callbacks; - const char *options[] = + const char *options[] = { "listening_ports", "24681", "document_root", "www", @@ -5381,7 +5399,7 @@ int ventoy_http_start(const char *ip, const char *port) ventoy_data_default_theme(g_data_theme + i); ventoy_data_default_menu_alias(g_data_menu_alias + i); ventoy_data_default_menu_class(g_data_menu_class + i); - ventoy_data_default_menu_tip(g_data_menu_tip + i); + ventoy_data_default_menu_tip(g_data_menu_tip + i); ventoy_data_default_auto_install(g_data_auto_install + i); ventoy_data_default_persistence(g_data_persistence + i); ventoy_data_default_injection(g_data_injection + i); @@ -5423,7 +5441,7 @@ int ventoy_http_stop(void) { if (g_ventoy_http_ctx) { - mg_stop(g_ventoy_http_ctx); + mg_stop(g_ventoy_http_ctx); } ventoy_stop_writeback_thread(); @@ -5433,7 +5451,7 @@ int ventoy_http_stop(void) int ventoy_http_init(void) { int i = 0; - + #ifdef VENTOY_SIM char *Buffer = NULL; int BufLen = 0; @@ -5450,7 +5468,7 @@ int ventoy_http_init(void) } #else ventoy_file *file; - + file = ventoy_tar_find_file("www/menulist"); if (file) { @@ -5466,7 +5484,7 @@ int ventoy_http_init(void) { g_pub_json_buffer = malloc(JSON_BUF_MAX * 2); g_pub_save_buffer = g_pub_json_buffer + JSON_BUF_MAX; - } + } pthread_mutex_init(&g_api_mutex, NULL); @@ -5478,7 +5496,7 @@ void ventoy_http_exit(void) check_free(g_pub_json_buffer); g_pub_json_buffer = NULL; g_pub_save_buffer = NULL; - + pthread_mutex_destroy(&g_api_mutex); } diff --git a/Plugson/src/Web/ventoy_http.h b/Plugson/src/Web/ventoy_http.h index f1c1737d..36c83efe 100644 --- a/Plugson/src/Web/ventoy_http.h +++ b/Plugson/src/Web/ventoy_http.h @@ -7,12 +7,12 @@ * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * @@ -37,7 +37,7 @@ typedef enum bios_mode bios_ia32, bios_aa64, bios_mips, - + bios_max }bios_mode; @@ -81,6 +81,8 @@ typedef struct data_control int linux_remount; int secondary_menu; int password_asterisk; + int uefi_res_lock; + int uefi_sb_policy; char default_search_root[MAX_PATH]; char default_image[MAX_PATH]; char default_kbd_layout[32]; @@ -110,7 +112,7 @@ typedef struct data_theme char ventoy_top[32]; char ventoy_color[32]; char serial_param[256]; - + path_node *fontslist; }data_theme; @@ -411,6 +413,9 @@ else\ #define CONTROL_PARSE_INT_DEF_1(node, val) \ if (node->unData.pcStrVal[0] == '0') val = 0 +#define CONTROL_PARSE_INT_DEF_3(node, val) \ + if (node->unData.pcStrVal[0] == '3') val = 3 + #define VTOY_JSON_INT(key, val) vtoy_json_get_int(json, key, &val) #define VTOY_JSON_STR(key, buf) vtoy_json_get_string(json, key, sizeof(buf), buf) #define VTOY_JSON_STR_EX(key) vtoy_json_get_string_ex(json, key) diff --git a/Plugson/www/buildtime b/Plugson/www/buildtime index 788f0ad3..2bd9ae4e 100644 --- a/Plugson/www/buildtime +++ b/Plugson/www/buildtime @@ -1 +1 @@ -20231014 18:52:12 \ No newline at end of file +20260624 16:39:09 \ No newline at end of file diff --git a/Plugson/www/helplist b/Plugson/www/helplist index 5c517416..7b99d9f9 100644 --- a/Plugson/www/helplist +++ b/Plugson/www/helplist @@ -1 +1 @@ -ar_ARbn_BNcs_CZde_DEel_GRen_USes_ESfr_FRhi_HIhr_HRhu_HUid_IDit_ITja_JPka_GEko_KRpl_PLpt_BRpt_PTru_RUsr_RSta_INtr_TRuk_UAzh_CNzh_TW \ No newline at end of file +ar_ARbn_BNcs_CZde_DEel_GRen_USes_ESfa_IRfr_FRhi_HIhr_HRhu_HUid_IDit_ITja_JPka_GEko_KRlg_UGpl_PLpt_BRpt_PTru_RUsl_SIsr_RSta_INtr_TRuk_UAvi_VNzh_CNzh_TW \ No newline at end of file diff --git a/Plugson/www/index.html b/Plugson/www/index.html index 5264188a..71bec73f 100644 --- a/Plugson/www/index.html +++ b/Plugson/www/index.html @@ -2,10 +2,10 @@ - - - - + + + + Ventoy Plugson @@ -22,7 +22,7 @@ - + - + Ventoy Plugson - + @@ -62,22 +65,22 @@ Preview - + - + English - + 捐助 - + @@ -85,12 +88,12 @@ Ventoy - + - - + + @@ -108,7 +111,7 @@ 全局控制插件 - + 主题插件 @@ -154,13 +157,13 @@ 密码插件 - + 文件列表插件 - + 自动 Memdisk 插件 @@ -196,13 +199,13 @@ - + - + - 请输入文件在当前系统中的全路径(注意是完整的绝对路径),例如: + 请输入文件在当前系统中的全路径(注意是完整的绝对路径),例如: @@ -210,7 +213,7 @@ - Please input the full absolute file path. For example: + Please input the full absolute file path. For example: @@ -284,22 +287,22 @@ - + - + - 请输入文件在当前系统中的全路径(注意是完整的绝对路径),例如: + 请输入文件在当前系统中的全路径(注意是完整的绝对路径),例如: - + - Please input the full absolute file path. For example: + Please input the full absolute file path. For example: @@ -317,18 +320,18 @@ - 请输入对应文件在当前系统中的全路径(注意是完整的绝对路径),例如: + 请输入对应文件在当前系统中的全路径(注意是完整的绝对路径),例如: - Please input the full absolute file path. For example: + Please input the full absolute file path. For example: - + - + - + - 请输入文件在当前系统中的全路径(注意是完整的绝对路径),例如: + 请输入文件在当前系统中的全路径(注意是完整的绝对路径),例如: - + - Please input the full absolute file path. For example: + Please input the full absolute file path. For example: @@ -390,18 +393,18 @@ - 请输入对应文件在当前系统中的全路径(注意是完整的绝对路径),例如: + 请输入对应文件在当前系统中的全路径(注意是完整的绝对路径),例如: - Please input the full absolute file path. For example: + Please input the full absolute file path. For example: - + - + - + - 请输入对应目录在当前系统中的全路径(注意是完整的绝对路径),例如: + 请输入对应目录在当前系统中的全路径(注意是完整的绝对路径),例如: - + - Please input the full absolute directory path. For example: + Please input the full absolute directory path. For example: @@ -461,18 +464,18 @@ - 请输入对应文件在当前系统中的全路径(注意是完整的绝对路径),例如: + 请输入对应文件在当前系统中的全路径(注意是完整的绝对路径),例如: - Please input the full absolute file path. For example: + Please input the full absolute file path. For example: - + - + - + - 请输入文件在当前系统中的全路径(注意是完整的绝对路径),例如: + 请输入文件在当前系统中的全路径(注意是完整的绝对路径),例如: - + - Please input the full absolute file path. For example: + Please input the full absolute file path. For example: @@ -529,7 +532,7 @@ - + @@ -552,19 +555,19 @@ - + - 新文件在当前系统中的全路径(注意是完整的绝对路径)例如: + 新文件在当前系统中的全路径(注意是完整的绝对路径)例如: - Please input the full absolute file path. For example: + Please input the full absolute file path. For example: @@ -579,7 +582,7 @@ - + @@ -597,9 +600,9 @@ - + - + @@ -607,7 +610,7 @@ - + @@ -615,27 +618,27 @@ - + xx - + - 请输入对应文件在当前系统中的全路径(注意是完整的绝对路径),例如: + 请输入对应文件在当前系统中的全路径(注意是完整的绝对路径),例如: - Please input the full absolute file path. For example: + Please input the full absolute file path. For example: @@ -676,7 +679,7 @@ - + - - + + - + × @@ -732,7 +735,7 @@ JSON Copy - + @@ -742,7 +745,7 @@ - + @@ -757,7 +760,7 @@ @@ -771,16 +774,16 @@ - + - - + + - - + + @@ -788,10 +791,10 @@ - + - +