Ignore:
Timestamp:
Aug 19, 2002, 11:23:17 PM (23 years ago)
Author:
umoeller
Message:

Dialog formatter rewrite.

File:
1 edited

Legend:

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

    r176 r209  
    176176 *@@changed V0.9.16 (2001-12-08) [umoeller]: speed optimizations, changed some return codes
    177177 *@@changed V0.9.16 (2002-01-04) [umoeller]: added fixes for COM, BAT, CMD extensions
     178 *@@changed V0.9.21 (2002-08-18) [umoeller]: this was completely broken for files without extensions (os2krnl)
    178179 */
    179180
     
    193194
    194195    if (!ppExec)
    195         return (ERROR_INVALID_PARAMETER);
     196        return ERROR_INVALID_PARAMETER;
    196197
    197198    if (!(pExec = (PEXECUTABLE)malloc(sizeof(EXECUTABLE))))
    198         return (ERROR_NOT_ENOUGH_MEMORY);
     199        return ERROR_NOT_ENOUGH_MEMORY;
    199200
    200201    memset(pExec, 0, sizeof(EXECUTABLE));
     
    202203    // check some of the default extensions
    203204    // V0.9.16 (2002-01-04) [umoeller]
    204     if (pExt = doshGetExtension(pcszExecutable))
     205    if (!(pExt = doshGetExtension(pcszExecutable)))
    205206    {
     207        // has no extension: then open file!
     208        // fixed V0.9.21 (2002-08-18) [umoeller]
     209        fOpenFile = TRUE;
     210    }
     211    else
     212    {
     213        // has extension:
    206214        if (!stricmp(pExt, "COM"))
    207215        {
     
    508516/*
    509517 *@@ ParseBldLevel:
    510  *      called from exehQueryBldLevel to parse
    511  *      the BLDLEVEL string.
    512  *
    513  *      On entry, caller has copied the string into
    514  *      pExec->pszDescription. The string is
    515  *      null-terminated.
    516  *
    517  *      The BLDLEVEL string comes in two flavors.
     518 *      called from exehQueryBldLevel to parse the BLDLEVEL string.
     519 *
     520 *      On entry, caller has copied the string into pExec->pszDescription.
     521 *      The string is null-terminated.
     522 *
     523 *      The BLDLEVEL string comes in at least two basic flavors.
    518524 *
    519525 *      --  The standard format is:
     
    524530 *          need to have them.
    525531 *
    526  *      --  However, there is an extended version
    527  *          in that the DESCRIPTION field is split
    528  *          up even more. The marker for this seems
    529  *          to be that the description starts out
    530  *          with "##1##".
     532 *      --  However, there is an extended version in that the DESCRIPTION field
     533 *          is split up even more.
     534 *
     535 *          I have seen two subformats for this.
     536 *
     537 *          --  DANIS506.ADD and some IBM programs have a marker that seems
     538 *              to be that the description starts out with "##1##".
    531539 *
    532540 +              ##1## DATETIME BUILDMACHINE:ASD:LANG:CTRY:REVISION:UNKNOWN:FIXPAK@@DESCRIPTION
    533541 *
    534  *          The problem is that the DATETIME field comes
    535  *          in several flavors. IBM uses things like
    536  *
    537  +              "Thu Nov 30 15:30:37 2000 BWBLD228"
    538  *
    539  *          while DANIS506.ADD has
    540  *
    541  +              "15.12.2000 18:22:57      Nachtigall"
    542  *
    543  *          Looks like the date/time string is standardized
    544  *          to have 24 characters then.
     542 *              The problem is that the DATETIME field comes
     543 *              in several flavors. IBM uses things like
     544 *
     545 +                  "Thu Nov 30 15:30:37 2000 BWBLD228"
     546 *
     547 *              while DANIS506.ADD has
     548 *
     549 +                  "15.12.2000 18:22:57      Nachtigall"
     550 *
     551 *              Looks like the date/time string is standardized to have 24 characters then.
     552 *
     553 *          --  IBM TCP/IP executables (try INETD.EXE) have something yet different on.
     554 *              We now try to parse that format as well, even though bldlevel.exe can't
     555 *              handle it. (Isn't that utility from IBM too?)
     556 *
     557 *              Here's what I get for inetd.exe:
     558 *
     559 +              ##built 09:16:27 Mon Sep 17 2001 -- On AURORA43;0.1@@ TCP/IP for OS/2: INETD
    545560 *
    546561 *@@added V0.9.12 (2001-05-18) [umoeller]
    547562 *@@changed V0.9.12 (2001-05-19) [umoeller]: added extended BLDLEVEL support
     563 *@@changed V0.9.21 (2002-08-18) [umoeller]: added support for IBM TCP/IP format
     564 *@@changed V0.9.21 (2002-08-18) [umoeller]: fixed DANIS506 format when an extended field had only one character
    548565 */
    549566
     
    555572
    556573    // @#VENDOR:VERSION#@ DESCRIPTION
    557     // but skip the first byte, which has the string length
    558574    if (    (pStartOfVendor = strstr(pExec->pszDescription, "@#"))
    559575         && (pStartOfInfo = strstr(pStartOfVendor + 2, "#@"))
     
    569585
    570586        // now check if we have extended DESCRIPTION V0.9.12 (2001-05-19) [umoeller]
    571         if (    (strlen(pStartOfInfo) > 6)
    572              && (!memcmp(pStartOfInfo, "##1##", 5))
    573            )
     587        if (strlen(pStartOfInfo) > 6)
    574588        {
    575             // yes: parse that beast
    576             const char *p = pStartOfInfo + 5;
    577 
    578             // get build date/time
    579             if (strlen(p) > 24)
     589            if (!memcmp(pStartOfInfo, "##1##", 5))
    580590            {
    581                 // date/time seems to be fixed 24 chars in length
    582                 if (pExec->pszBuildDateTime = (PSZ)malloc(25))
    583                 {
    584                     memcpy(pExec->pszBuildDateTime,
     591                // DANIS506.ADD format:
     592                // "##1## 2.7.2002 19:32:34        Nachtigall::::6::@@..."
     593
     594                // parse that beast
     595                PCSZ p = pStartOfInfo + 5;
     596
     597                // get build date/time
     598                if (strlen(p) > 24)
     599                {
     600                    // skip leading and trailing spaces
     601                    // V0.9.21 (2002-08-18) [umoeller]
     602                    PCSZ pStartOfDT = p,
     603                         pEndOfDT = p + 24;
     604                                // date/time seems to be fixed 24 chars in length
     605
     606                    while (*pStartOfDT == ' ')
     607                        ++pStartOfDT;
     608
     609                    while (    (*pEndOfDT == ' ')
     610                            && (pEndOfDT > pStartOfDT)
     611                          )
     612                        --pEndOfDT;
     613
     614                    pExec->pszBuildDateTime = strhSubstr(pStartOfDT, pEndOfDT + 1);
     615
     616                    /* memcpy(pExec->pszBuildDateTime,
    585617                           p,
    586618                           24);
    587619                    pExec->pszBuildDateTime[24] = '\0';
    588 
     620                    */
     621
     622                    // date/time seems to be fixed 24 chars in length
    589623                    p += 24;
    590624
     
    613647                             ul++)
    614648                        {
    615                             BOOL fStop = FALSE;
    616                             const char *pNextColon = strchr(p, ':'),
    617                                        *pDoubleAt = strstr(p, "@@");
     649                            BOOL    fStop = FALSE;
     650                            PCSZ    pNextColon = strchr(p, ':'),
     651                                    pDoubleAt = strstr(p, "@@");
    618652                            if (!pNextColon)
    619653                            {
     
    635669                               )
    636670                            {
    637                                 if (pNextColon > p + 1)
     671                                // if (pNextColon > p + 1)
     672                                        // fixed V0.9.21 (2002-08-18) [umoeller]
     673                                        // this failed on fields like "revision"
     674                                        // which only had one character
     675                                if (pNextColon > p)
    638676                                    *(papsz[ul]) = strhSubstr(p, pNextColon);
    639677                            }
     
    648686                    }
    649687                }
     688
     689                if (pStartOfInfo = strstr(p,
     690                                          "@@"))
     691                    pStartOfInfo += 2;
     692            } // end if (!memcmp(pStartOfInfo, "##1##", 5))
     693            else if (!memcmp(pStartOfInfo, "##built", 7))
     694            {
     695                // IBM TCP/IP format:
     696                // V0.9.21 (2002-08-18) [umoeller]
     697
     698                // ##built 09:16:27 Mon Sep 17 2001 -- On AURORA43;0.1@@ TCP/IP for OS/2: INETD
     699
     700                PCSZ    p = pStartOfInfo + 7,
     701                        p2,
     702                        p3;
     703
     704                if (p3 = strchr(p, ';'))
     705                {
     706                    while (*p == ' ')
     707                        ++p;
     708
     709                    // ##built 09:16:27 Mon Sep 17 2001 -- On AURORA43;0.1@@ TCP/IP for OS/2: INETD
     710                    //         ^ p                                    ^ p3
     711                    //                                 ^ p2
     712
     713                    if (    (p2 = strstr(p, " -- On "))
     714                         && (p2 < p3)
     715                       )
     716                    {
     717                        pExec->pszBuildMachine = strhSubstr(p2 + 7, p3);
     718                        pExec->pszBuildDateTime = strhSubstr(p, p2);
     719                    }
     720                    else
     721                        pExec->pszBuildDateTime = strhSubstr(p, p3);
     722
     723                    p = p3 + 1;
     724                }
     725
     726                if (pStartOfInfo = strstr(p,
     727                                          "@@"))
     728                {
     729                    if (pStartOfInfo > p3)
     730                    {
     731                        // p3 points to this "0.1" string; I assume this is
     732                        // a "revision.fixpak" format since inetver reports
     733                        // four digits with this revision
     734                        PCSZ p4;
     735                        if (    (p4 = strchr(p3, '.'))
     736                             && (p4 < pStartOfInfo)
     737                           )
     738                        {
     739                            pExec->pszRevision = strhSubstr(p3 + 1, p4);
     740                            pExec->pszFixpak = strhSubstr(p4 + 1, pStartOfInfo);
     741                        }
     742                        else
     743                            pExec->pszRevision = strhSubstr(p3 + 1, pStartOfInfo);
     744                    }
     745
     746                    pStartOfInfo += 2;
     747                }
    650748            }
    651 
    652             pStartOfInfo = strstr(p,
    653                                   "@@");
    654             if (pStartOfInfo)
    655                 pStartOfInfo += 2;
    656749        }
    657750
     
    666759            // skip leading spaces in info string
    667760            while (*pStartOfInfo == ' ')
    668                 pStartOfInfo++;
     761                ++pStartOfInfo;
     762
    669763            if (*pStartOfInfo)  // V0.9.9 (2001-04-04) [umoeller]
    670764                // and copy until end of string
     
    21422236static APIRET ExpandIterdata1(char *pabTarget,         // out: page data (pagesize as in lx spec)
    21432237                              int cbTarget,            // in: sizeof *pabTarget (pagesize as in lx spec)
    2144                               const char *pabSource,   // in: compressed source data in EXEPACK:1 format
     2238                              PCSZ pabSource,   // in: compressed source data in EXEPACK:1 format
    21452239                              int cbSource)            // in: sizeof *pabSource
    21462240{
     
    22052299 */
    22062300
    2207 static void memcpyw(char *pch1, const char *pch2, size_t cch)
     2301static void memcpyw(char *pch1, PCSZ pch2, size_t cch)
    22082302{
    22092303    /*
     
    22392333 */
    22402334
    2241 static void memcpyb(char *pch1, const char *pch2, size_t cch)
     2335static void memcpyb(char *pch1, PCSZ pch2, size_t cch)
    22422336{
    22432337    /*
     
    22762370static APIRET ExpandIterdata2(char *pachPage,              // out: page data (pagesize as in lx spec)
    22772371                              int cchPage,                 // in: sizeof *pachPage (pagesize as in lx spec)
    2278                               const char *pachSrcPage,     // in: compressed source data in EXEPACK:1 format
     2372                              PCSZ pachSrcPage,     // in: compressed source data in EXEPACK:1 format
    22792373                              int cchSrcPage)              // in: size of source buf
    22802374{
     
    31823276}
    31833277
     3278
Note: See TracChangeset for help on using the changeset viewer.