]> code.delx.au - refind/blobdiff - refind/config.c
Added support for "-c" command-line parameter to rEFInd, to specify
[refind] / refind / config.c
index e9d2e559f1248fde8171e56151270d26e73fb135..a3e3900f504fa2342842923883f05f224c15e5e5 100644 (file)
@@ -342,36 +342,15 @@ static VOID HandleStrings(IN CHAR16 **TokenList, IN UINTN TokenCount, OUT CHAR16
 
 // 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 +360,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
@@ -432,7 +411,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);
@@ -626,7 +605,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]);
            }
@@ -865,7 +845,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]);
             }