Changeset 69 for trunk/src


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

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

Location:
trunk/src/helpers
Files:
5 edited

Legend:

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

    r64 r69  
    230230    }
    231231    return (pszReturn);
     232}
     233
     234/*
     235 *@@ doshQuerySysUptime:
     236 *      returns the system uptime in milliseconds.
     237 *      This can be used for time comparisons.
     238 *
     239 *@@added V0.9.12 (2001-05-18) [umoeller]
     240 */
     241
     242ULONG doshQuerySysUptime(VOID)
     243{
     244    ULONG ulms;
     245    DosQuerySysInfo(QSV_MS_COUNT,
     246                    QSV_MS_COUNT,
     247                    &ulms,
     248                    sizeof(ulms));
     249    return (ulms);
    232250}
    233251
  • 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                        }
  • trunk/src/helpers/stringh.c

    r56 r69  
    11151115 *@@ strhBeautifyTitle:
    11161116 *      replaces all line breaks (0xd, 0xa) with spaces.
     1117 *
     1118 *@@changed V0.9.12 (2001-05-17) [pr]: multiple line break chars. end up as only 1 space
    11171119 */
    11181120
     
    11201122{
    11211123    BOOL rc = FALSE;
    1122     CHAR *p;
    1123     while ((p = strchr(psz, 0xa)))
    1124     {
    1125         *p = ' ';
    1126         rc = TRUE;
    1127     }
    1128     while ((p = strchr(psz, 0xd)))
    1129     {
    1130         *p = ' ';
    1131         rc = TRUE;
    1132     }
     1124    CHAR *p = psz;
     1125
     1126    while(*p)
     1127        if (   (*p == '\r')
     1128            || (*p == '\n')
     1129           )
     1130        {
     1131            rc = TRUE;
     1132            if (   (p != psz)
     1133                && (p[-1] == ' ')
     1134               )
     1135                memmove(p, p + 1, strlen(p));
     1136            else
     1137                *p++ = ' ';
     1138        }
     1139        else
     1140            p++;
     1141
    11331142    return (rc);
    11341143}
  • trunk/src/helpers/timer.c

    r68 r69  
    443443                    PXTIMER pTimer = (PXTIMER)pTimerNode->pItemData;
    444444
    445                     if (pTimer->ulNextFire < ulTimeNow)
     445                    if (    (pTimer)
     446                         && (pTimer->ulNextFire < ulTimeNow)
     447                       )
    446448                    {
    447449                        // this timer has elapsed:
  • trunk/src/helpers/winh.c

    r62 r69  
    5757#define INCL_WINPROGRAMLIST
    5858#define INCL_WINSWITCHLIST
     59#define INCL_WINBUTTONS
    5960#define INCL_WINMENUS
    6061#define INCL_WINSCROLLBARS
     
    8889
    8990/*
     91 *@@category: Helpers\PM helpers\Wrappers
     92 */
     93
     94/* ******************************************************************
     95 *
     96 *   Wrappers
     97 *
     98 ********************************************************************/
     99
     100#ifdef WINH_STANDARDWRAPPERS
     101
     102    /*
     103     *@@ winhSendMsg:
     104     *      wrapper for WinSendMsg.
     105     *
     106     *      If WINH_STANDARDWRAPPERS is #defined before
     107     *      including win.h, all WinSendMsg calls are
     108     *      redefined to use this wrapper instead. This
     109     *      reduces the amount of external fixups required
     110     *      for loading the module.
     111     *
     112     *@@added V0.9.12 (2001-05-18) [umoeller]
     113     */
     114
     115    MRESULT winhSendMsg(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     116    {
     117        // put the call in brackets so the macro won't apply here
     118        return ((WinSendMsg)(hwnd, msg, mp1, mp2));
     119    }
     120
     121    /*
     122     *@@ winhPostMsg:
     123     *      wrapper for WinPostMsg.
     124     *
     125     *      If WINH_STANDARDWRAPPERS is #defined before
     126     *      including win.h, all WinSendMsg calls are
     127     *      redefined to use this wrapper instead. This
     128     *      reduces the amount of external fixups required
     129     *      for loading the module.
     130     *
     131     *@@added V0.9.12 (2001-05-18) [umoeller]
     132     */
     133
     134    BOOL winhPostMsg(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     135    {
     136        // put the call in brackets so the macro won't apply here
     137        return ((WinPostMsg)(hwnd, msg, mp1, mp2));
     138    }
     139
     140    /*
     141     *@@ winhWindowFromID:
     142     *
     143     *@@added V0.9.12 (2001-05-18) [umoeller]
     144     */
     145
     146    HWND winhWindowFromID(HWND hwnd, ULONG id)
     147    {
     148        // put the call in brackets so the macro won't apply here
     149        return ((WinWindowFromID)(hwnd, id));
     150    }
     151
     152    /*
     153     *@@ winhQueryWindow:
     154     *
     155     *@@added V0.9.12 (2001-05-18) [umoeller]
     156     */
     157
     158    HWND winhQueryWindow(HWND hwnd, LONG lCode)
     159    {
     160        // put the call in brackets so the macro won't apply here
     161        return ((WinQueryWindow)(hwnd, lCode));
     162    }
     163
     164#endif // WINH_STANDARDWRAPPERS
     165
     166/*
    90167 *@@category: Helpers\PM helpers\Rectangle helpers
    91168 */
     
    119196
    120197/*
     198 *@@category: Helpers\PM helpers\Generics
     199 */
     200
     201/* ******************************************************************
     202 *
     203 *   Generics
     204 *
     205 ********************************************************************/
     206
     207/*
     208 *@@ winhSetDlgItemChecked:
     209 *      checks a check box.
     210 *
     211 *      This has been turned into a real function
     212 *      because this is used hundreds of times in
     213 *      XWP, and each WinSendDlgItemMsg in each
     214 *      macro produced a fixup relocation record.
     215 *
     216 *@@added V0.9.12 (2001-05-18) [umoeller]
     217 */
     218
     219BOOL winhSetDlgItemChecked(HWND hwnd,       // in: dialog
     220                           SHORT id,        // in: dialog item ID
     221                           SHORT bCheck)    // in: 0, 1, or (for tri-state) 2
     222{
     223    return ((BOOL)WinSendDlgItemMsg(hwnd,
     224                                    id,
     225                                    BM_SETCHECK,
     226                                    MPFROMSHORT(bCheck),
     227                                    MPNULL));
     228}
     229
     230/*
     231 *@@ winhIsDlgItemChecked:
     232 *      returns the current check state of the
     233 *      specified check box, which can be 0, 1,
     234 *      or (for tri-state checkboxes) 2.
     235 *
     236 *@@added V0.9.12 (2001-05-18) [umoeller]
     237 */
     238
     239SHORT winhIsDlgItemChecked(HWND hwnd,       // in: dialog
     240                           SHORT id)        // in: dialog item ID
     241{
     242    return (SHORT1FROMMR(WinSendDlgItemMsg(hwnd,
     243                                           id,
     244                                           BM_QUERYCHECK,
     245                                           MPNULL,
     246                                           MPNULL)));
     247}
     248
     249/*
     250 *@@ winhEnableDlgItem:
     251 *
     252 *@@added V0.9.12 (2001-05-18) [umoeller]
     253 */
     254
     255BOOL winhEnableDlgItem(HWND hwndDlg,
     256                       SHORT id,
     257                       BOOL fEnable)
     258{
     259    return (WinEnableWindow(WinWindowFromID(hwndDlg, id), fEnable));
     260}
     261
     262/*
     263 *@@ winhIsDlgItemEnabled:
     264 *
     265 *@@added V0.9.12 (2001-05-18) [umoeller]
     266 */
     267
     268BOOL winhIsDlgItemEnabled(HWND hwndDlg,
     269                          SHORT id)
     270{
     271    return (WinIsWindowEnabled(WinWindowFromID(hwndDlg, id)));
     272}
     273
     274
     275/*
    121276 *@@category: Helpers\PM helpers\Menu helpers
    122277 */
     
    127282 *
    128283 ********************************************************************/
     284
     285/*
     286 *@@ winhQueryMenuItem:
     287 *      wrapper around MM_QUERYITEM.
     288 *
     289 *@@added V0.9.12 (2001-05-18) [umoeller]
     290 */
     291
     292BOOL winhQueryMenuItem(HWND hwndMenu,
     293                       USHORT usItemID,
     294                       BOOL fSearchSubmenus,
     295                       PMENUITEM pmi)           // out: MENUITEM data
     296{
     297    return ((BOOL)WinSendMsg(hwndMenu,
     298                             MM_QUERYITEM,
     299                             MPFROM2SHORT(usItemID, fSearchSubmenus),
     300                             (MPARAM)pmi));
     301}
    129302
    130303/*
     
    15251698                                                    // which considers this inclusive!
    15261699                         LONG ulViewportPels,       // in: total viewport dimension,
    1527                                                     // into which *plCurPelsOfs is an offset
     1700                                                    // into which *pulCurPelsOfs is an offset
    15281701                         USHORT usLineStepPels,     // in: pixels to scroll line-wise
    15291702                                                    // (scroll bar buttons pressed)
     
    16021775    if (*pulCurPelsOfs > (lMaxAllowedUnitOfs * usScrollUnitPels))
    16031776    {
    1604         // _Pmpf(("        !!! limiting 2: %d to %d", *plCurUnitOfs, lMaxAllowedUnitOfs));
    16051777        *pulCurPelsOfs = (lMaxAllowedUnitOfs * usScrollUnitPels);
    16061778    }
Note: See TracChangeset for help on using the changeset viewer.