]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
Improvement for multi-mode option.
authorlongpanda <admin@ventoy.net>
Wed, 27 Oct 2021 12:08:47 +0000 (20:08 +0800)
committerlongpanda <admin@ventoy.net>
Wed, 27 Oct 2021 12:08:47 +0000 (20:08 +0800)
Now you can use for example theme_uefi and theme at the same time.

GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_plugin.c

index 82a5754d16b2c7fd4a58f4f8583e38f27c0ce7be..9c41c8898039b83bc4c9306b17951f35566039f6 100644 (file)
@@ -550,6 +550,7 @@ typedef struct plugin_entry
     const char *key;
     ventoy_plugin_entry_pf entryfunc;
     ventoy_plugin_check_pf checkfunc;
     const char *key;
     ventoy_plugin_entry_pf entryfunc;
     ventoy_plugin_check_pf checkfunc;
+    int flag;
 }plugin_entry;
 
 typedef struct replace_fs_dir
 }plugin_entry;
 
 typedef struct replace_fs_dir
index e260440920cf25a123bbe0c46e58fa5f0b50ef62..3a47de6ad021272f39e9d261fe59277143686f91 100644 (file)
@@ -2338,45 +2338,55 @@ static int ventoy_plugin_image_list_check(VTOY_JSON *json, const char *isodisk)
 
 static plugin_entry g_plugin_entries[] = 
 {
 
 static plugin_entry g_plugin_entries[] = 
 {
-    { "control", ventoy_plugin_control_entry, ventoy_plugin_control_check },
-    { "theme", ventoy_plugin_theme_entry, ventoy_plugin_theme_check },
-    { "auto_install", ventoy_plugin_auto_install_entry, ventoy_plugin_auto_install_check },
-    { "persistence", ventoy_plugin_persistence_entry, ventoy_plugin_persistence_check },
-    { "menu_alias", ventoy_plugin_menualias_entry, ventoy_plugin_menualias_check },
-    { "menu_tip", ventoy_plugin_menutip_entry, ventoy_plugin_menutip_check },
-    { "menu_class", ventoy_plugin_menuclass_entry, ventoy_plugin_menuclass_check },
-    { "injection", ventoy_plugin_injection_entry, ventoy_plugin_injection_check },
-    { "auto_memdisk", ventoy_plugin_auto_memdisk_entry, ventoy_plugin_auto_memdisk_check },
-    { "image_list", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check },
-    { "image_blacklist", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check },
-    { "conf_replace", ventoy_plugin_conf_replace_entry, ventoy_plugin_conf_replace_check },
-    { "dud", ventoy_plugin_dud_entry, ventoy_plugin_dud_check },
-    { "password", ventoy_plugin_pwd_entry, ventoy_plugin_pwd_check },
-    { "custom_boot", ventoy_plugin_custom_boot_entry, ventoy_plugin_custom_boot_check },
+    { "control", ventoy_plugin_control_entry, ventoy_plugin_control_check, 0 },
+    { "theme", ventoy_plugin_theme_entry, ventoy_plugin_theme_check, 0 },
+    { "auto_install", ventoy_plugin_auto_install_entry, ventoy_plugin_auto_install_check, 0 },
+    { "persistence", ventoy_plugin_persistence_entry, ventoy_plugin_persistence_check, 0 },
+    { "menu_alias", ventoy_plugin_menualias_entry, ventoy_plugin_menualias_check, 0 },
+    { "menu_tip", ventoy_plugin_menutip_entry, ventoy_plugin_menutip_check, 0 },
+    { "menu_class", ventoy_plugin_menuclass_entry, ventoy_plugin_menuclass_check, 0 },
+    { "injection", ventoy_plugin_injection_entry, ventoy_plugin_injection_check, 0 },
+    { "auto_memdisk", ventoy_plugin_auto_memdisk_entry, ventoy_plugin_auto_memdisk_check, 0 },
+    { "image_list", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check, 0 },
+    { "image_blacklist", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check, 0 },
+    { "conf_replace", ventoy_plugin_conf_replace_entry, ventoy_plugin_conf_replace_check, 0 },
+    { "dud", ventoy_plugin_dud_entry, ventoy_plugin_dud_check, 0 },
+    { "password", ventoy_plugin_pwd_entry, ventoy_plugin_pwd_check, 0 },
+    { "custom_boot", ventoy_plugin_custom_boot_entry, ventoy_plugin_custom_boot_check, 0 },
 };
 
 static int ventoy_parse_plugin_config(VTOY_JSON *json, const char *isodisk)
 {
     int i;
     char key[128];
 };
 
 static int ventoy_parse_plugin_config(VTOY_JSON *json, const char *isodisk)
 {
     int i;
     char key[128];
-    VTOY_JSON *cur = json;
+    VTOY_JSON *cur = NULL;
 
     grub_snprintf(g_iso_disk_name, sizeof(g_iso_disk_name), "%s", isodisk);
 
 
     grub_snprintf(g_iso_disk_name, sizeof(g_iso_disk_name), "%s", isodisk);
 
-    while (cur)
+    for (cur = json; cur; cur = cur->pstNext)
     {
         for (i = 0; i < (int)ARRAY_SIZE(g_plugin_entries); i++)
         {
             grub_snprintf(key, sizeof(key), "%s_%s", g_plugin_entries[i].key, g_arch_mode_suffix);
     {
         for (i = 0; i < (int)ARRAY_SIZE(g_plugin_entries); i++)
         {
             grub_snprintf(key, sizeof(key), "%s_%s", g_plugin_entries[i].key, g_arch_mode_suffix);
-            if (grub_strcmp(g_plugin_entries[i].key, cur->pcName) == 0 || grub_strcmp(key, cur->pcName) == 0)
+            if (g_plugin_entries[i].flag == 0 && grub_strcmp(key, cur->pcName) == 0)
             {
                 debug("Plugin entry for %s\n", g_plugin_entries[i].key);
                 g_plugin_entries[i].entryfunc(cur, isodisk);
             {
                 debug("Plugin entry for %s\n", g_plugin_entries[i].key);
                 g_plugin_entries[i].entryfunc(cur, isodisk);
+                g_plugin_entries[i].flag = 1;
+                break;
+            }
+        }
+        
+        for (i = 0; i < (int)ARRAY_SIZE(g_plugin_entries); i++)
+        {
+            if (g_plugin_entries[i].flag == 0 && grub_strcmp(g_plugin_entries[i].key, cur->pcName) == 0)
+            {
+                debug("Plugin entry for %s\n", g_plugin_entries[i].key);
+                g_plugin_entries[i].entryfunc(cur, isodisk);
+                g_plugin_entries[i].flag = 1;
                 break;
             }
         }
                 break;
             }
         }
-    
-        cur = cur->pstNext;
     }
 
     return 0;
     }
 
     return 0;