]> code.delx.au - refind/blobdiff - refind/config.c
Using "+" as first option to use_graphics_for, also_scan_dirs,
[refind] / refind / config.c
index f86edc836fb8fc597446e45c1459eba2312db1e8..103436ebf5179ede4aa86ea4158317b326cc3eba 100644 (file)
@@ -324,54 +324,43 @@ static VOID HandleString(IN CHAR16 **TokenList, IN UINTN TokenCount, OUT CHAR16
    } // if
 } // static VOID HandleString()
 
-// Handle a parameter with a series of string arguments, to be added to a comma-delimited
-// list. Passes each token through the CleanUpPathNameSlashes() function to ensure
-// consistency in subsequent comparisons of filenames.
+// Handle a parameter with a series of string arguments, to replace or be added to a
+// comma-delimited list. Passes each token through the CleanUpPathNameSlashes() function
+// to ensure consistency in subsequent comparisons of filenames. If the first
+// non-keyword token is "+", the list is added to the existing target string; otherwise,
+// the tokens replace the current string.
 static VOID HandleStrings(IN CHAR16 **TokenList, IN UINTN TokenCount, OUT CHAR16 **Target) {
    UINTN i;
+   BOOLEAN AddMode = FALSE;
 
-   if (*Target != NULL) {
+   if ((TokenCount > 2) && (StriCmp(TokenList[1], L"+") == 0)) {
+      Print(L"Entering add mode in HandleStrings for '%s'\n", TokenList[0]);
+      AddMode = TRUE;
+   }
+
+   if ((*Target != NULL) && !AddMode) {
       FreePool(*Target);
       *Target = NULL;
    } // if
    for (i = 1; i < TokenCount; i++) {
-      CleanUpPathNameSlashes(TokenList[i]);
-      MergeStrings(Target, TokenList[i], L',');
-   }
+      if ((i != 1) || !AddMode) {
+         CleanUpPathNameSlashes(TokenList[i]);
+         MergeStrings(Target, TokenList[i], L',');
+      } // if
+   } // for
 } // static VOID HandleStrings()
 
 // Convert TimeString (in "HH:MM" format) to a pure-minute format. Values should be
 // in the range from 0 (for 00:00, or midnight) to 1439 (for 23:59; aka LAST_MINUTE).
-// Any value outside that range denotes an error in the specification.
-// static UINTN HandleTime(IN CHAR16 *TimeString) {
-//    BOOLEAN Found = FALSE;
-//    UINTN ColonPosition = 0, Hour = 0, Minute = 0, TimeLength;
-// 
-//    Print(L"Entering HandleTime('%s')\n", TimeString);
-//    TimeLength = StrLen(TimeString);
-//    for (ColonPosition = 0; (ColonPosition < TimeLength) && !Found; ColonPosition++) {
-//       Print(L"ColonPosition = %d\n", ColonPosition);
-//       if (TimeString[ColonPosition] == ':')
-//          Found = TRUE;
-//    } // for
-// 
-//    if ((ColonPosition == 0) || (ColonPosition > StrLen(TimeString)))
-//       return (LAST_MINUTE + 1);
-// 
-//    Hour = Atoi(TimeString);
-//    Minute = Atoi(&TimeString[ColonPosition + 1]);
-//    Print(L"Hour = %d, Minute = %d\n", Hour, Minute);
-//    return (Hour * 60 + Minute);
-// } // BOOLEAN HandleTime()
-
+// Any value outside that range denotes an error in the specification. Note that if
+// the input is a number that includes no colon, this function will return the original
+// number in UINTN form.
 static UINTN HandleTime(IN CHAR16 *TimeString) {
    UINTN Hour = 0, Minute = 0, TimeLength, i = 0;
-   BOOLEAN FoundColon = FALSE;
 
    TimeLength = StrLen(TimeString);
    while (i < TimeLength) {
       if (TimeString[i] == L':') {
-         FoundColon = TRUE;
          Hour = Minute;
          Minute = 0;
       } // if
@@ -381,7 +370,7 @@ static UINTN HandleTime(IN CHAR16 *TimeString) {
       } // if
       i++;
    } // while
-   return (FoundColon ? Hour * 60 + Minute : LAST_MINUTE + 1);
+   return (Hour * 60 + Minute);
 } // BOOLEAN HandleTime()
 
 // Sets the default boot loader IF the current time is within the bounds
@@ -397,6 +386,8 @@ static VOID SetDefaultByTime(IN CHAR16 **TokenList, OUT CHAR16 **Default) {
 
    if ((StartTime <= LAST_MINUTE) && (EndTime <= LAST_MINUTE)) {
       Status = refit_call2_wrapper(GetTime, &CurrentTime, NULL);
+      if (Status != EFI_SUCCESS)
+         return;
       Now = CurrentTime.Hour * 60 + CurrentTime.Minute;
 
       if (Now > LAST_MINUTE) { // Shouldn't happen; just being paranoid
@@ -430,7 +421,7 @@ VOID ReadConfig(CHAR16 *FileName)
     UINTN           TokenCount, i;
 
     // Set a few defaults only if we're loading the default file.
-    if (StriCmp(FileName, CONFIG_FILE_NAME) == 0) {
+    if (StriCmp(FileName, GlobalConfig.ConfigFilename) == 0) {
        MyFreePool(GlobalConfig.AlsoScan);
        GlobalConfig.AlsoScan = StrDuplicate(ALSO_SCAN_DIRS);
        MyFreePool(GlobalConfig.DontScanDirs);
@@ -596,7 +587,8 @@ VOID ReadConfig(CHAR16 *FileName)
            HandleInt(TokenList, TokenCount, &(GlobalConfig.ScreensaverTime));
 
         } else if (StriCmp(TokenList[0], L"use_graphics_for") == 0) {
-           GlobalConfig.GraphicsFor = 0;
+           if ((TokenCount == 2) || ((TokenCount > 2) && (StriCmp(TokenList[1], L"+") != 0)))
+              GlobalConfig.GraphicsFor = 0;
            for (i = 1; i < TokenCount; i++) {
               if (StriCmp(TokenList[i], L"osx") == 0) {
                  GlobalConfig.GraphicsFor |= GRAPHICS_FOR_OSX;
@@ -624,7 +616,8 @@ VOID ReadConfig(CHAR16 *FileName)
         } else if (StriCmp(TokenList[0], L"max_tags") == 0) {
            HandleInt(TokenList, TokenCount, &(GlobalConfig.MaxTags));
 
-        } else if ((StriCmp(TokenList[0], L"include") == 0) && (TokenCount == 2) && (StriCmp(FileName, CONFIG_FILE_NAME) == 0)) {
+        } else if ((StriCmp(TokenList[0], L"include") == 0) && (TokenCount == 2) &&
+                   (StriCmp(FileName, GlobalConfig.ConfigFilename) == 0)) {
            if (StriCmp(TokenList[1], FileName) != 0) {
               ReadConfig(TokenList[1]);
            }
@@ -633,6 +626,12 @@ VOID ReadConfig(CHAR16 *FileName)
 
         FreeTokenLine(&TokenList, &TokenCount);
     }
+    Print(L"also_scan_dirs = '%s'\n", GlobalConfig.AlsoScan);
+    Print(L"dont_scan_dirs = '%s'\n", GlobalConfig.DontScanDirs);
+    Print(L"dont_scan_files = '%s'\n", GlobalConfig.DontScanFiles);
+    Print(L"scan_driver_dirs = '%s'\n", GlobalConfig.DriverDirs);
+    Print(L"use_graphics_for = %d\n", GlobalConfig.GraphicsFor);
+    PauseForKey();
     MyFreePool(File.Buffer);
 } /* VOID ReadConfig() */
 
@@ -863,7 +862,8 @@ VOID ScanUserConfigured(CHAR16 *FileName)
             } // if/else
             MyFreePool(Title);
 
-         } else if ((StriCmp(TokenList[0], L"include") == 0) && (TokenCount == 2) && (StriCmp(FileName, CONFIG_FILE_NAME) == 0)) {
+         } else if ((StriCmp(TokenList[0], L"include") == 0) && (TokenCount == 2) &&
+                    (StriCmp(FileName, GlobalConfig.ConfigFilename) == 0)) {
             if (StriCmp(TokenList[1], FileName) != 0) {
                ScanUserConfigured(TokenList[1]);
             }