+static int parse_custom_setup_path(char *cmdline, const char **path, char *exefile)
+{
+ int i = 0;
+ int len = 0;
+ char *pos1 = NULL;
+ char *pos2 = NULL;
+
+ if ((cmdline[0] == 'x' || cmdline[0] == 'X') && cmdline[1] == ':')
+ {
+ pos1 = pos2 = cmdline + 3;
+
+ while (i < VTOY_MAX_DIR_DEPTH && *pos2)
+ {
+ while (*pos2 && *pos2 != '\\' && *pos2 != '/')
+ {
+ pos2++;
+ }
+
+ path[i++] = pos1;
+
+ if (*pos2 == 0)
+ {
+ break;
+ }
+
+ *pos2 = 0;
+ pos1 = pos2 + 1;
+ pos2 = pos1;
+ }
+
+ if (i == 0 || i >= VTOY_MAX_DIR_DEPTH)
+ {
+ return 1;
+ }
+ }
+ else
+ {
+ path[i++] = "Windows";
+ path[i++] = "System32";
+ path[i++] = cmdline;
+ }
+
+ pos1 = (char *)path[i - 1];
+ while (*pos1 != ' ' && *pos1 != '\t' && *pos1)
+ {
+ pos1++;
+ }
+ *pos1 = 0;
+
+ len = (int)grub_strlen(path[i - 1]);
+ if (len < 4 || grub_strcasecmp(path[i - 1] + len - 4, ".exe") != 0)
+ {
+ grub_snprintf(exefile, 256, "%s.exe", path[i - 1]);
+ path[i - 1] = exefile;
+ }
+
+
+ debug("custom setup: %d <%s>\n", i, path[i - 1]);
+ return 0;
+}
+