Ignore:
Timestamp:
May 19, 2001, 3:47:20 PM (24 years ago)
Author:
umoeller
Message:

New folder sorting. Updated folder refresh. Misc other changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/dosh2.c

    r67 r69  
    11151115
    11161116/*
     1117 *@@ ParseBldLevel:
     1118 *      called from doshExecQueryBldLevel to parse
     1119 *      the BLDLEVEL string.
     1120 *
     1121 *      On entry, caller has copied the string into
     1122 *      pExec->pszDescription. The string is
     1123 *      null-terminated.
     1124 *
     1125 *      The BLDLEVEL string comes in two flavors.
     1126 *
     1127 *      --  The standard format is:
     1128 *
     1129 +              @#VENDOR:VERSION#@DESCRIPTION
     1130 *
     1131 *          DESCRIPTION can have leading spaces, but
     1132 *          need to have them.
     1133 *
     1134 *      --  However, there is an extended version
     1135 *          in that the DESCRIPTION field is split
     1136 *          up even more. The marker for this seems
     1137 *          to be that the description starts out
     1138 *          with "##1##".
     1139 *
     1140 +              ##1## DATETIME BUILDMACHINE:ASD:LANG:CTRY:REVISION:UNKNOWN:FIXPAK@@DESCRIPTION
     1141 *
     1142 *          The problem is that the DATETIME field comes
     1143 *          in several flavors. IBM uses things like
     1144 *
     1145 +              "Thu Nov 30 15:30:37 2000 BWBLD228"
     1146 *
     1147 *          while DANIS506.ADD has
     1148 *
     1149 +              "15.12.2000 18:22:57      Nachtigall"
     1150 *
     1151 *          Looks like the date/time string is standardized
     1152 *          to have 24 characters then.
     1153 *
     1154 *@@added V0.9.12 (2001-05-18) [umoeller]
     1155 *@@changed V0.9.12 (2001-05-19) [umoeller]: added extended BLDLEVEL support
     1156 */
     1157
     1158VOID ParseBldLevel(PEXECUTABLE pExec)
     1159{
     1160    const char  *pStartOfAuthor = 0,
     1161                *pStartOfVendor = 0;
     1162
     1163    // @#VENDOR:VERSION#@ DESCRIPTION
     1164    // but skip the first byte, which has the string length
     1165    pStartOfVendor = strstr(pExec->pszDescription,
     1166                            "@#");
     1167    if (pStartOfVendor)
     1168    {
     1169        const char *pStartOfInfo = strstr(pStartOfVendor + 2,
     1170                                          "#@");
     1171        if (pStartOfInfo)
     1172        {
     1173            const char *pEndOfVendor = strchr(pStartOfVendor + 2,
     1174                                              ':');
     1175            if (pEndOfVendor)
     1176            {
     1177                pExec->pszVendor = strhSubstr(pStartOfVendor + 2,
     1178                                              pEndOfVendor);
     1179                pExec->pszVersion = strhSubstr(pEndOfVendor + 1,
     1180                                               pStartOfInfo);
     1181                // skip "@#" in DESCRIPTION string
     1182                pStartOfInfo += 2;
     1183
     1184                // now check if we have extended DESCRIPTION V0.9.12 (2001-05-19) [umoeller]
     1185                if (    (strlen(pStartOfInfo) > 6)
     1186                     && (!memcmp(pStartOfInfo, "##1##", 5))
     1187                   )
     1188                {
     1189                    // yes: parse that beast
     1190                    const char *p = pStartOfInfo + 5;
     1191
     1192                    // get build date/time
     1193                    if (strlen(p) > 24)
     1194                    {
     1195                        // date/time seems to be fixed 24 chars in length
     1196                        pExec->pszBuildDateTime = (PSZ)malloc(25);
     1197                        if (pExec->pszBuildDateTime)
     1198                        {
     1199                            memcpy(pExec->pszBuildDateTime,
     1200                                   p,
     1201                                   24);
     1202                            pExec->pszBuildDateTime[24] = '\0';
     1203
     1204                            p += 24;
     1205
     1206                            // now we're at the colon-separated
     1207                            // strings, first of which is the
     1208                            // build machine;
     1209                            // skip leading spaces
     1210                            while (*p == ' ')
     1211                                p++;
     1212
     1213                            if (*p)
     1214                            {
     1215                                char **papsz[] =
     1216                                    {
     1217                                        &pExec->pszBuildMachine,
     1218                                        &pExec->pszASD,
     1219                                        &pExec->pszLanguage,
     1220                                        &pExec->pszCountry,
     1221                                        &pExec->pszRevision,
     1222                                        &pExec->pszUnknown,
     1223                                        &pExec->pszFixpak
     1224                                    };
     1225                                ULONG ul;
     1226
     1227                                for (ul = 0;
     1228                                     ul < sizeof(papsz) / sizeof(papsz[0]);
     1229                                     ul++)
     1230                                {
     1231                                    BOOL fStop = FALSE;
     1232                                    const char *pNextColon = strchr(p, ':'),
     1233                                               *pDoubleAt = strstr(p, "@@");
     1234                                    if (!pNextColon)
     1235                                    {
     1236                                        // last item:
     1237                                        if (pDoubleAt)
     1238                                            pNextColon = pDoubleAt;
     1239                                        else
     1240                                            pNextColon = p + strlen(p);
     1241
     1242                                        fStop = TRUE;
     1243                                    }
     1244
     1245                                    if (    (fStop)
     1246                                         || (    (pNextColon)
     1247                                              && (    (!pDoubleAt)
     1248                                                   || (pNextColon < pDoubleAt)
     1249                                                 )
     1250                                            )
     1251                                       )
     1252                                    {
     1253                                        if (pNextColon > p + 1)
     1254                                            *(papsz[ul]) = strhSubstr(p, pNextColon);
     1255                                    }
     1256                                    else
     1257                                        break;
     1258
     1259                                    if (fStop)
     1260                                        break;
     1261
     1262                                    p = pNextColon + 1;
     1263                                }
     1264                            }
     1265                        }
     1266                    }
     1267
     1268                    pStartOfInfo = strstr(p,
     1269                                          "@@");
     1270                    if (pStartOfInfo)
     1271                        pStartOfInfo += 2;
     1272                }
     1273
     1274                // -- if we had no extended DESCRIPTION,
     1275                //    pStartOfInfo points to regular description now
     1276                // -- if we parse the extended DESCRIPTION above,
     1277                //    pStartOfInfo points to after @@ now
     1278                // -- if we had an error, pStartOfInfo is NULL
     1279                if (pStartOfInfo)
     1280                {
     1281                    // add the regular DESCRIPTION then
     1282                    // skip leading spaces in info string
     1283                    while (*pStartOfInfo == ' ')
     1284                        pStartOfInfo++;
     1285                    if (*pStartOfInfo)  // V0.9.9 (2001-04-04) [umoeller]
     1286                        // and copy until end of string
     1287                        pExec->pszInfo = strdup(pStartOfInfo);
     1288                }
     1289            }
     1290        }
     1291    }
     1292}
     1293
     1294/*
    11171295 *@@ doshExecQueryBldLevel:
    11181296 *      this retrieves buildlevel information for an
     
    11681346 *@@changed V0.9.1 (99-12-06): fixed memory leak
    11691347 *@@changed V0.9.9 (2001-04-04) [umoeller]: added more error checking
     1348 *@@changed V0.9.12 (2001-05-18) [umoeller]: extracted ParseBldLevel
    11701349 */
    11711350
     
    12431422                            else
    12441423                            {
    1245                                 const char  *pStartOfAuthor = 0,
    1246                                             *pStartOfVendor = 0;
    1247 
    12481424                                memcpy(pExec->pszDescription,
    12491425                                       pszNameTable + 1,        // skip length byte
     
    12521428                                *(pExec->pszDescription + (*pszNameTable)) = 0;
    12531429
    1254                                 // now parse the damn thing:
    1255                                 // @#VENDOR:VERSION#@ DESCRIPTION
    1256                                 // but skip the first byte, which has the string length
    1257                                 pStartOfVendor = strstr(pExec->pszDescription,
    1258                                                         "@#");
    1259                                 if (pStartOfVendor)
    1260                                 {
    1261                                     const char *pStartOfInfo = strstr(pStartOfVendor + 2,
    1262                                                                       "#@");
    1263                                     if (pStartOfInfo)
    1264                                     {
    1265                                         PSZ pEndOfVendor = strchr(pStartOfVendor + 2,
    1266                                                                   ':');
    1267                                         if (pEndOfVendor)
    1268                                         {
    1269                                             pExec->pszVendor = strhSubstr(pStartOfVendor + 2,
    1270                                                                           pEndOfVendor);
    1271                                             pExec->pszVersion = strhSubstr(pEndOfVendor + 1,
    1272                                                                            pStartOfInfo);
    1273                                             // skip "@#" in info string
    1274                                             pStartOfInfo += 2;
    1275                                             // skip leading spaces in info string
    1276                                             while (*pStartOfInfo == ' ')
    1277                                                 pStartOfInfo++;
    1278                                             if (*pStartOfInfo)  // V0.9.9 (2001-04-04) [umoeller]
    1279                                                 // and copy until end of string
    1280                                                 pExec->pszInfo = strdup(pStartOfInfo);
    1281                                         }
    1282                                     }
    1283                                 }
     1430                                ParseBldLevel(pExec);
    12841431                            }
    12851432                        }
Note: See TracChangeset for help on using the changeset viewer.