VirtualBox

Changeset 93143 in vbox


Ignore:
Timestamp:
Jan 7, 2022 9:01:56 PM (3 years ago)
Author:
vboxsync
Message:

Add/os2: Some simplifications to the installer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/os2/VBoxOs2AdditionsInstall.cpp

    r93142 r93143  
    526526
    527527
    528 /*********************************************************************************************************************************
    529 *   Installation Steps.                                                                                                          *
    530 *********************************************************************************************************************************/
    531 
    532528/**
    533  * Checks that the necessary GRADD components are present.
    534  */
    535 static RTEXITCODE CheckForGradd(void)
    536 {
    537     strcpy(&g_szBootDrivePath[g_cchBootDrivePath], "OS2\\DLL\\GENGRADD.DLL");
    538     FILESTATUS3 FileSts;
    539     APIRET rc = DosQueryPathInfo(g_szBootDrivePath, FIL_STANDARD, &FileSts, sizeof(FileSts));
    540     if (rc != NO_ERROR)
    541         return ApiErrorN(rc, 3, "DosQueryPathInfo(\"", g_szBootDrivePath, "\",,,) - installed gengradd?");
    542 
    543     /* Note! GRADD precense in Config.sys is checked below while modifying it. */
    544     return RTEXITCODE_SUCCESS;
     529 * Matches a word deliminated by space of @a chAltSep.
     530 *
     531 * @returns true if matched, false if not.
     532 * @param   pchLine     The line we're working on.
     533 * @param   off         The current line offset.
     534 * @param   cchLine     The current line length.
     535 * @param   pszWord     The word to match with.
     536 * @param   cchWord     The length of the word to match.
     537 * @param   chAltSep    Alternative word separator, optional.
     538 */
     539static bool MatchWord(const char *pchLine, size_t off, size_t cchLine, const char *pszWord, size_t cchWord, char chAltSep = ' ')
     540{
     541    pchLine += off;
     542    cchLine -= off;
     543    if (cchWord <= cchLine)
     544        if (MyMemICmp(pchLine, pszWord, cchWord) == 0)
     545            if (   cchWord == cchLine
     546                || RT_C_IS_BLANK(pchLine[cchWord])
     547                || pchLine[cchWord] == chAltSep)
     548                return true;
     549    return false;
    545550}
    546551
     
    599604
    600605
     606/*********************************************************************************************************************************
     607*   Installation Steps.                                                                                                          *
     608*********************************************************************************************************************************/
     609
     610/**
     611 * Checks that the necessary GRADD components are present.
     612 */
     613static RTEXITCODE CheckForGradd(void)
     614{
     615    strcpy(&g_szBootDrivePath[g_cchBootDrivePath], "OS2\\DLL\\GENGRADD.DLL");
     616    FILESTATUS3 FileSts;
     617    APIRET rc = DosQueryPathInfo(g_szBootDrivePath, FIL_STANDARD, &FileSts, sizeof(FileSts));
     618    if (rc != NO_ERROR)
     619        return ApiErrorN(rc, 3, "DosQueryPathInfo(\"", g_szBootDrivePath, "\",,,) - installed gengradd?");
     620
     621    /* Note! GRADD precense in Config.sys is checked below while modifying it. */
     622    return RTEXITCODE_SUCCESS;
     623}
     624
     625
    601626/** Adds DEVICE=[path]\VBoxGuest.sys to the modified Config.sys. */
    602627static bool ConfigSysAddVBoxGuest(void)
     
    726751    const char *pchGraddChains = "C1";
    727752    size_t      cchGraddChains = sizeof("C1") - 1;
    728     char        ch0GraddUpper  = 'C';
    729     char        ch0GraddLower  = 'c';
    730753    const char *pchGraddChain1 = NULL;
    731754    size_t      cchGraddChain1 = NULL;
     
    750773         * If there are multiple SET PATH statements, we add ourselves to all of them.
    751774         */
    752         if (   cchLine - off >= sizeof("SET PATH=") - 1
    753             && (pchLine[off + 0] == 'S' || pchLine[off + 0] == 's')
    754             && (pchLine[off + 1] == 'E' || pchLine[off + 1] == 'e')
    755             && (pchLine[off + 2] == 'T' || pchLine[off + 2] == 't')
    756             && RT_C_IS_BLANK(pchLine[off + 3]))
    757         {
    758             off += 4;
     775        if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("SET")))
     776        {
     777            off += sizeof("SET") - 1;
    759778            SKIP_BLANKS();
    760             if (   cchLine - off >= sizeof("PATH=") - 1
    761                 && (pchLine[off + 0] == 'P' || pchLine[off + 0] == 'p')
    762                 && (pchLine[off + 1] == 'A' || pchLine[off + 1] == 'a')
    763                 && (pchLine[off + 2] == 'T' || pchLine[off + 2] == 't')
    764                 && (pchLine[off + 3] == 'H' || pchLine[off + 3] == 'h'))
     779            if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("PATH"), '='))
    765780            {
    766                 off += 4;
     781                off += sizeof("PATH") - 1;
    767782                SKIP_BLANKS();
    768783                if (cchLine > off && pchLine[off] == '=')
     
    800815             * other values can only be done by users or special drivers.
    801816             */
    802             else if (   cchLine - off >= sizeof("GRADD_CHAINS=C") - 1
    803                      && (pchLine[off +  0] == 'G' || pchLine[off + 0] == 'g')
    804                      && (pchLine[off + 12] == '=' || RT_C_IS_BLANK(pchLine[off + 12]))
    805                      && MyMemICmp(&pchLine[off], RT_STR_TUPLE("GRADD_CHAINS")) == 0)
     817            else if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("GRADD_CHAINS"), '='))
    806818            {
    807                 off += 12;
     819                off += sizeof("GRADD_CHAINS") - 1;
    808820                SKIP_BLANKS();
    809821                if (cchLine > off && pchLine[off] == '=')
     
    831843                        pchGraddChains = pchNew;
    832844                        cchGraddChains = cchNew;
    833                         ch0GraddUpper  = RT_C_TO_UPPER(*pchGraddChains);
    834                         ch0GraddLower  = RT_C_TO_LOWER(*pchGraddChains);
    835845                        pchGraddChain1 = NULL;
    836846                        cchGraddChain1 = 0;
     
    846856             * Look for the chains listed by GRADD_CHAINS.
    847857             */
    848             else if (   (ch0GraddUpper == pchLine[off] || ch0GraddLower == pchLine[off])
    849                      && cchLine - off >= cchGraddChains + 2
    850                      && (pchLine[off + cchGraddChains] == '=' || RT_C_IS_SPACE(pchLine[off + cchGraddChains]))
    851                      && MyMemICmp(&pchLine[off], pchGraddChains, cchGraddChains) == 0)
     858            else if (MatchWord(pchLine, off, cchLine, pchGraddChains, cchGraddChains, '='))
    852859            {
    853860                off += cchGraddChains;
     
    873880         * Look for that IFS that should be loaded before we can load our drivers.
    874881         */
    875         else if (   cchLine - off >= sizeof("IFS=XX.IFS") - 1
    876                  && (pchLine[off + 0] == 'I' || pchLine[off + 0] == 'i')
    877                  && (pchLine[off + 1] == 'F' || pchLine[off + 1] == 'f')
    878                  && (pchLine[off + 2] == 'S' || pchLine[off + 2] == 's')
    879                  && (pchLine[off + 3] == '=' || RT_C_IS_BLANK(pchLine[off + 3])) )
    880         {
    881             off += 3;
     882        else if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("IFS"), '='))
     883        {
     884            off += sizeof("IFS") - 1;
    882885            SKIP_BLANKS();
    883886            if (cchLine > off && pchLine[off] == '=')
     
    915918         * as well as older VBoxGuest.sys statements we should remove.
    916919         */
    917         else if (   cchLine - off >= sizeof("DEVICE=XX.SYS") - 1
    918                  && (pchLine[off + 0] == 'D' || pchLine[off + 0] == 'd')
    919                  && (pchLine[off + 1] == 'E' || pchLine[off + 1] == 'e')
    920                  && (pchLine[off + 2] == 'V' || pchLine[off + 2] == 'v')
    921                  && (pchLine[off + 3] == 'I' || pchLine[off + 3] == 'i')
    922                  && (pchLine[off + 4] == 'C' || pchLine[off + 4] == 'c')
    923                  && (pchLine[off + 5] == 'E' || pchLine[off + 5] == 'e')
    924                  && (pchLine[off + 6] == '=' || RT_C_IS_BLANK(pchLine[off + 6])) )
    925         {
    926             off += 6;
     920        else if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("DEVICE"), '='))
     921        {
     922            off += sizeof("DEVICE") - 1;
    927923            SKIP_BLANKS();
    928924            if (cchLine > off && pchLine[off] == '=')
     
    10961092            SKIP_BLANKS();
    10971093        }
    1098         if (   cchLine - off < sizeof("ECHO OFF") - 1
    1099             && MyMemICmp(&pchLine[off], RT_STR_TUPLE("ECHO")) == 0
    1100             && RT_C_IS_BLANK(pchLine[off + 4]) )
    1101         {
    1102             off += 4;
     1094        if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("ECHO")))
     1095        {
     1096            off += sizeof("ECHO") - 1;
    11031097            SKIP_BLANKS();
    11041098
    1105             if (   cchLine - off < sizeof("OFF") - 1
    1106                 && MyMemICmp(&pchLine[off], RT_STR_TUPLE("OFF")) == 0
    1107                 && RT_C_IS_BLANK(pchLine[off + 3]) )
     1099            if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("OFF")))
    11081100            {
    11091101                iInsertBeforeLine = iLine + 1;
     
    11111103            }
    11121104        }
    1113         else if (   cchLine - off < sizeof("REM") - 1
    1114                 && MyMemICmp(&pchLine[off], RT_STR_TUPLE("REM")) == 0
    1115                 && (cchLine - off == 3 || RT_C_IS_BLANK(pchLine[off + 3])) )
     1105        else if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("REM")))
    11161106        { /* skip */ }
    11171107        else
     
    11451135        }
    11461136
    1147         if (   cchLine - off < sizeof("DETACH ") - 1
    1148             && MyMemICmp(&pchLine[off], RT_STR_TUPLE("DETACH")) == 0
    1149             && RT_C_IS_BLANK(pchLine[off + 6]))
    1150         {
    1151             off += 6;
     1137        if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("DETACH")))
     1138        {
     1139            off += sizeof("DEATCH") - 1;
    11521140            SKIP_BLANKS();
    11531141        }
    11541142
    1155         if (   cchLine - off < sizeof("CALL ") - 1
    1156             && MyMemICmp(&pchLine[off], RT_STR_TUPLE("CALL")) == 0
    1157             && RT_C_IS_BLANK(pchLine[off + 4]))
    1158         {
    1159             off += 4;
     1143        if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("CALL")))
     1144        {
     1145            off += sizeof("CALL") - 1;
    11601146            SKIP_BLANKS();
    11611147        }
    11621148
    1163         if (   cchLine - off < sizeof("START ") - 1
    1164             && MyMemICmp(&pchLine[off], RT_STR_TUPLE("START")) == 0
    1165             && RT_C_IS_BLANK(pchLine[off + 5]))
    1166         {
    1167             off += 5;
     1149        if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("START")))
     1150        {
     1151            off += sizeof("START") - 1;
    11681152            SKIP_BLANKS();
    11691153        }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette