Changeset 116


Ignore:
Timestamp:
Nov 1, 2001, 6:43:18 PM (24 years ago)
Author:
umoeller
Message:

More updates.

Location:
trunk/src/helpers
Files:
9 edited

Legend:

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

    r111 r116  
    133133 *
    134134 *@@added V0.9.13 (2001-06-21) [umoeller]
     135 *@@changed V0.9.16 (2001-10-24) [umoeller]: fixed wrong hatch color and paint offset
     136 *@@changed V0.9.16 (2001-10-28) [umoeller]: added bitmap support, fixed bad clip rectangle
    135137 */
    136138
     
    172174    {
    173175        // button border:
    174 
    175176        // now paint button frame
     177
     178        // make rcl inclusive
    176179        rclWin.xRight--;
    177180        rclWin.yTop--;
     
    203206        cy = rclWin.yTop - rclWin.yBottom;
    204207
    205         ptl.x = rclWin.xLeft + ((cx - pxbd->cxMiniIcon) / 2);
    206         ptl.y = rclWin.yBottom + ((cy - pxbd->cxMiniIcon) / 2);
     208        ptl.x = rclWin.xLeft + ((cx - pxbd->cxIconOrBitmap) / 2);
     209        ptl.y = rclWin.yBottom + ((cy - pxbd->cyIconOrBitmap) / 2);
    207210
    208211        if (fl & XBF_INUSE)
     
    214217            ptl2.y = ptl.y - 2;
    215218            GpiMove(hps,
    216                     &ptl);
     219                    &ptl2);     // &ptl
     220                                // duh, typo V0.9.16 (2001-10-24) [umoeller]
    217221            GpiSetPattern(hps, PATSYM_DIAG1);
    218             ptl2.x = ptl.x + pxbd->cxMiniIcon + 1; // inclusive!
    219             ptl2.y = ptl.y + pxbd->cxMiniIcon + 1; // inclusive!
     222            GpiSetColor(hps, RGBCOL_BLACK);     // V0.9.16 (2001-10-24) [umoeller]
     223            ptl2.x = ptl.x + pxbd->cxIconOrBitmap + 1; // inclusive!
     224            ptl2.y = ptl.y + pxbd->cyIconOrBitmap + 1; // inclusive!
    220225            GpiBox(hps,
    221226                   DRO_FILL,
     
    226231
    227232        // now paint icon
    228         GpiIntersectClipRectangle(hps, &rclWin);    // exclusive!
    229         WinDrawPointer(hps,
    230                        // center this in remaining rectl
    231                        ptl.x + ulOfs,
    232                        ptl.y - ulOfs,
    233                        pxbd->hptr,
    234                        DP_MINI);
     233
     234        // make rcl inclusive           // V0.9.16 (2001-10-28) [umoeller]
     235        rclWin.xRight--;
     236        rclWin.yTop--;
     237        GpiIntersectClipRectangle(hps,
     238                                  &rclWin);    // inclusive!
     239
     240        // center this in remaining rectl
     241        ptl.x += ulOfs;
     242        ptl.y -= ulOfs;
     243        if (fl & XBF_BITMAP)
     244            // V0.9.16 (2001-10-28) [umoeller]
     245            WinDrawBitmap(hps,
     246                          pxbd->hptr,           // a bitmap really
     247                          NULL,                 // entire bitmap
     248                          &ptl,
     249                          0,
     250                          0,
     251                          DBM_NORMAL);
     252        else
     253            WinDrawPointer(hps,
     254                           // center this in remaining rectl
     255                           ptl.x + ulOfs,
     256                           ptl.y - ulOfs,
     257                           pxbd->hptr,
     258                           DP_MINI);
    235259    }
    236260}
  • trunk/src/helpers/dosh.c

    r113 r116  
    6464#include <stdio.h>
    6565#include <stdarg.h>
     66#include <ctype.h>
    6667
    6768#include "setup.h"                      // code generation and debugging options
     
    357358 */
    358359
    359 PVOID doshRequestSharedMem(const char *pcszName)
     360PVOID doshRequestSharedMem(PCSZ pcszName)
    360361{
    361362    PVOID pvrc = NULL;
     
    682683
    683684VOID doshEnumDrives(PSZ pszBuffer,      // out: drive letters
    684                     const char *pcszFileSystem,  // in: FS's to match or NULL
     685                    PCSZ pcszFileSystem,  // in: FS's to match or NULL
    685686                    BOOL fSkipRemoveables) // in: if TRUE, only non-removeable disks will be returned
    686687{
     
    11911192
    11921193/*
    1193  *@@category: Helpers\Control program helpers\File management
     1194 *@@category: Helpers\Control program helpers\File name parsing
    11941195 */
    11951196
    11961197/* ******************************************************************
    11971198 *
    1198  *   File helpers
     1199 *   File name parsing
    11991200 *
    12001201 ********************************************************************/
     1202
     1203/*
     1204 *@@ doshGetDriveSpec:
     1205 *      returns the drive specification in pcszFullFile,
     1206 *      if any is present. This is useful for UNC support.
     1207 *
     1208 *      This returns:
     1209 *
     1210 *      --  NO_ERROR: drive spec was given, and the output
     1211 *          fields have been set.
     1212 *
     1213 *      --  ERROR_INVALID_NAME: incorrect UNC syntax.
     1214 *
     1215 *      --  ERROR_INVALID_DRIVE: second char is ':', but
     1216 *          drive letter is not in the range [A-Z].
     1217 *
     1218 *      --  ERROR_INVALID_PARAMETER: no drive spec given
     1219 *          at all; apparently pcszFullFile is not fully
     1220 *          qualified in the first place, or it is NULL,
     1221 *          or its length is <= 2.
     1222 *
     1223 *@@added V0.9.16 (2001-10-25) [umoeller]
     1224 */
     1225
     1226APIRET doshGetDriveSpec(PCSZ pcszFullFile,      // in: fully q'fied file spec
     1227                        PSZ pszDrive,           // out: drive spec ("C:" or "\\SERVER\RESOURCE"; ptr can be NULL)
     1228                        PULONG pulDriveLen,     // out: length of drive spec (2 if local drive; ptr can be NULL)
     1229                        PBOOL pfIsUNC)          // out: set to TRUE if UNC name, FALSE otherwise (ptr can be NULL)
     1230{
     1231    APIRET  arc = NO_ERROR;
     1232    ULONG   ulFileSpecLength;
     1233
     1234    if (    (pcszFullFile)
     1235         && (ulFileSpecLength = strlen(pcszFullFile))
     1236         && (ulFileSpecLength >= 2)
     1237       )
     1238    {
     1239        // upper-case the drive letter
     1240        if (pcszFullFile[1] == ':')
     1241        {
     1242            CHAR cDrive = toupper(*pcszFullFile);
     1243            // local drive specified:
     1244            if (    (cDrive >= 'A')
     1245                 && (cDrive <= 'Z')
     1246               )
     1247            {
     1248                if (pszDrive)
     1249                {
     1250                    pszDrive[0] = cDrive;
     1251                    pszDrive[1] = ':';
     1252                    pszDrive[2] = '\0';
     1253                }
     1254
     1255                if (pulDriveLen)
     1256                    *pulDriveLen = 2;
     1257                if (pfIsUNC)
     1258                    *pfIsUNC = FALSE;
     1259            }
     1260            else
     1261                // this is not a valid drive:
     1262                arc = ERROR_INVALID_DRIVE;
     1263        }
     1264        else if (    (pcszFullFile[0] == '\\')
     1265                  && (pcszFullFile[1] == '\\')
     1266                )
     1267        {
     1268            // UNC drive specified:
     1269            // this better be a full \\SERVER\RESOURCE string
     1270            PCSZ pResource;
     1271            if (pResource = strchr(pcszFullFile + 3, '\\'))
     1272            {
     1273                // we got at least \\SERVER\:
     1274                ULONG ulLength;
     1275                PCSZ p;
     1276
     1277                // check if more stuff is coming
     1278                if (p = strchr(pResource + 1, '\\'))
     1279                {
     1280                    // yes: copy server and resource excluding that backslash
     1281                    if (p == pResource + 1)
     1282                        // "\\SERVER\\" is invalid
     1283                        arc = ERROR_INVALID_NAME;
     1284                    else
     1285                        // we got "\\SERVER\something\":
     1286                        // drop the last backslash
     1287                        ulLength = p - pcszFullFile;
     1288                }
     1289                else
     1290                    // "\\SERVER\something" only:
     1291                    ulLength = ulFileSpecLength;
     1292
     1293                if (!arc)
     1294                {
     1295                    if (pszDrive)
     1296                    {
     1297                        memcpy(pszDrive,
     1298                               pcszFullFile,
     1299                               ulLength);
     1300                        pszDrive[ulLength] = '\0';
     1301                    }
     1302
     1303                    if (pulDriveLen)
     1304                        *pulDriveLen = ulLength;
     1305                    if (pfIsUNC)
     1306                        *pfIsUNC = TRUE;
     1307                }
     1308            }
     1309            else
     1310                // invalid UNC name:
     1311                arc = ERROR_INVALID_NAME;
     1312        }
     1313        else
     1314            // neither local, nor UNC:
     1315            arc = ERROR_INVALID_PARAMETER;
     1316    }
     1317    else
     1318        arc = ERROR_INVALID_PARAMETER;
     1319
     1320    return (arc);
     1321}
    12011322
    12021323/*
     
    12161337 */
    12171338
    1218 PSZ doshGetExtension(const char *pcszFilename)
     1339PSZ doshGetExtension(PCSZ pcszFilename)
    12191340{
    12201341    PSZ pReturn = NULL;
     
    12231344    {
    12241345        // find filename
    1225         const char *p2 = strrchr(pcszFilename + 2, '\\'),
     1346        PCSZ    p2 = strrchr(pcszFilename + 2, '\\'),
    12261347                            // works on "C:\blah" or "\\unc\blah"
    1227                    *pStartOfName = NULL,
    1228                    *pExtension = NULL;
     1348                pStartOfName = NULL,
     1349                pExtension = NULL;
    12291350
    12301351        if (p2)
     
    12341355            // no backslash found:
    12351356            // maybe only a drive letter was specified:
    1236             if (*(pcszFilename + 1) == ':')
     1357            if (pcszFilename[1] == ':')
    12371358                // yes:
    12381359                pStartOfName = pcszFilename + 2;
     
    12511372    return (pReturn);
    12521373}
     1374
     1375/*
     1376 *@@category: Helpers\Control program helpers\File management
     1377 */
     1378
     1379/* ******************************************************************
     1380 *
     1381 *   File helpers
     1382 *
     1383 ********************************************************************/
    12531384
    12541385/*
     
    14451576 */
    14461577
    1447 APIRET doshOpenExisting(const char *pcszFilename,   // in: file name
     1578APIRET doshOpenExisting(PCSZ pcszFilename,   // in: file name
    14481579                        ULONG ulOpenFlags,          // in: open flags
    14491580                        HFILE *phf)                 // out: OS/2 file handle
     
    15521683 */
    15531684
    1554 APIRET doshOpen(const char *pcszFilename,   // in: filename to open
     1685APIRET doshOpen(PCSZ pcszFilename,   // in: filename to open
    15551686                ULONG ulOpenMode,       // in: XOPEN_* mode
    15561687                PULONG pcbFile,         // in: new file size (if new file is created)
     
    17561887
    17571888            arc = doshWrite(pFile,
    1758                             (PVOID)szTemp,
     1889                            (PCSZ)szTemp,
    17591890                            ulLength);
    17601891        }
     
    18231954 */
    18241955
    1825 APIRET doshLoadTextFile(const char *pcszFile,  // in: file name to read
     1956APIRET doshLoadTextFile(PCSZ pcszFile,  // in: file name to read
    18261957                        PSZ* ppszContent)      // out: newly allocated buffer with file's content
    18271958{
     
    19602091
    19612092APIRET doshCreateTempFileName(PSZ pszTempFileName,        // out: fully q'fied temp file name
    1962                               const char *pcszDir,        // in: dir or NULL for %TEMP%
    1963                               const char *pcszPrefix,     // in: prefix for temp file or NULL
    1964                               const char *pcszExt)        // in: extension (without dot) or NULL
     2093                              PCSZ pcszDir,        // in: dir or NULL for %TEMP%
     2094                              PCSZ pcszPrefix,     // in: prefix for temp file or NULL
     2095                              PCSZ pcszExt)        // in: extension (without dot) or NULL
    19652096{
    19662097    APIRET      arc = NO_ERROR;
     
    21722303 */
    21732304
    2174 BOOL doshQueryDirExist(const char *pcszDir)
     2305BOOL doshQueryDirExist(PCSZ pcszDir)
    21752306{
    21762307    FILESTATUS3 fs3;
     
    21952326 */
    21962327
    2197 APIRET doshCreatePath(const char *pcszPath,
     2328APIRET doshCreatePath(PCSZ pcszPath,
    21982329                      BOOL fHidden) // in: if TRUE, the new directories will get FILE_HIDDEN
    21992330{
     
    23042435 */
    23052436
    2306 APIRET doshDeleteDir(const char *pcszDir,
     2437APIRET doshDeleteDir(PCSZ pcszDir,
    23072438                     ULONG flFlags,
    23082439                     PULONG pulDirs,        // out: directories found
     
    28442975 */
    28452976
    2846 APIRET doshExecVIO(const char *pcszExecWithArgs,
     2977APIRET doshExecVIO(PCSZ pcszExecWithArgs,
    28472978                   PLONG plExitCode)            // out: exit code (ptr can be NULL)
    28482979{
     
    29263057 */
    29273058
    2928 APIRET doshQuickStartSession(const char *pcszPath,       // in: program to start
    2929                              const char *pcszParams,     // in: parameters for program
     3059APIRET doshQuickStartSession(PCSZ pcszPath,       // in: program to start
     3060                             PCSZ pcszParams,     // in: parameters for program
    29303061                             BOOL fForeground,  // in: if TRUE, session will be in foreground
    29313062                             USHORT usPgmCtl,   // in: STARTDATA.PgmControl
  • trunk/src/helpers/lan.c

    r114 r116  
    145145        PSERVER pBuf;
    146146        ULONG cb = 4096;            // set this fixed, can't get it to work otherwise
    147         if (pBuf = doshMalloc(cb,
    148                               &arc))
     147        if (pBuf = (PSERVER)doshMalloc(cb,
     148                                       &arc))
    149149        {
    150150            if (!(arc = pNet32ServerEnum2(NULL,
    151151                                          1,          // ulLevel
    152                                           (PBYTE)pBuf,       // pbBuffer
     152                                          (PUCHAR)pBuf,       // pbBuffer
    153153                                          cb,          // cbBuffer,
    154154                                          &ulEntriesRead, // *pcEntriesRead,
  • trunk/src/helpers/nls.c

    r113 r116  
    3939    // as unsigned char
    4040
     41#define INCL_DOSNLS
     42#define INCL_DOSERRORS
    4143#define INCL_WINSHELLDATA
    4244#include <os2.h>
     
    455457}
    456458
     459
     460/*
     461 *@@ nlsUpper:
     462 *      quick hack for upper-casing a string.
     463 *
     464 *      This uses DosMapCase with the default system country
     465 *      code and the process's codepage.
     466 *
     467 *@@added V0.9.16 (2001-10-25) [umoeller]
     468 */
     469
     470APIRET nlsUpper(PSZ psz,            // in/out: string
     471                ULONG ulLength)     // in: string length; if 0, we run strlen(psz)
     472{
     473    COUNTRYCODE cc;
     474
     475    if (psz)
     476    {
     477        if (!ulLength)
     478            ulLength = strlen(psz);
     479
     480        if (ulLength)
     481        {
     482            cc.country = 0;         // use system country code
     483            cc.codepage = 0;        // use process default codepage
     484            return (DosMapCase(ulLength,
     485                               &cc,
     486                               psz));
     487        }
     488    }
     489
     490    return (ERROR_INVALID_PARAMETER);
     491}
  • trunk/src/helpers/stringh.c

    r108 r116  
    9595
    9696PSZ strhdupDebug(const char *pszSource,
     97                 unsigned long *pulLength,
    9798                 const char *pcszSourceFile,
    9899                 unsigned long ulLine,
    99100                 const char *pcszFunction)
    100101{
    101     if (pszSource)
    102     {
    103         PSZ p = (PSZ)memdMalloc(strlen(pszSource) + 1,
    104                                 pcszSourceFile,
    105                                 ulLine,
    106                                 pcszFunction);
    107         strcpy(p,  pszSource);
    108         return (p);
    109     }
    110     else
    111         return (0);
     102    PSZ     pszReturn = NULL;
     103    ULONG   ulLength = 0;
     104
     105    if (    (pcszSource)
     106         && (ulLength = strlen(pcszSource))
     107       )
     108    {
     109        if (pszReturn = (PSZ)memdMalloc(ulLength + 1,
     110                                        pcszSourceFile,
     111                                        ulLine,
     112                                        pcszFunction))
     113            memcpy(pszReturn, pcszSource, ulLength + 1);
     114    }
     115
     116    if (pulLength)
     117        *pulLength = ulLength;
     118
     119    return (pszReturn);
    112120}
    113121
     
    116124/*
    117125 *@@ strhdup:
    118  *      like strdup, but this one doesn't crash if pszSource is NULL,
    119  *      but returns NULL also.
     126 *      like strdup, but this one doesn't crash if pszSource
     127 *      is NULL, but returns NULL also. In addition, this
     128 *      can report the length of the string (V0.9.16).
    120129 *
    121130 *@@added V0.9.0 [umoeller]
    122  */
    123 
    124 PSZ strhdup(const char *pszSource)
    125 {
    126     if (pszSource)
    127         return (strdup(pszSource));
    128     else
    129         return (0);
     131 *@@changed V0.9.16 (2001-10-25) [umoeller]: added pulLength
     132 */
     133
     134PSZ strhdup(const char *pcszSource,
     135            unsigned long *pulLength)       // out: length of string excl. null terminator (ptr can be NULL)
     136{
     137    PSZ     pszReturn = NULL;
     138    ULONG   ulLength = 0;
     139
     140    if (    (pcszSource)
     141         && (ulLength = strlen(pcszSource))
     142       )
     143    {
     144        if (pszReturn = (PSZ)malloc(ulLength + 1))
     145            memcpy(pszReturn, pcszSource, ulLength + 1);
     146    }
     147
     148    if (pulLength)
     149        *pulLength = ulLength;
     150
     151    return (pszReturn);
    130152}
    131153
  • trunk/src/helpers/threads.c

    r100 r116  
    146146                    // run thread func
    147147                    ((PTHREADFUNC)pti->pThreadFunc)(pti);
    148 
    149148                    WinDestroyMsgQueue(pti->hmq);
    150 
    151149                }
    152150                WinTerminate(pti->hab);
     
    247245 *         the HMQ in its THREADINFO. These are automatically
    248246 *         destroyed when the thread terminates.
     247 *
     248 *         WARNING: Be careful with this setting for short-lived
     249 *         threads which are started synchronously while some
     250 *         other thread is locking PM, e.g. in a WinSendMsg
     251 *         call. While creation of the thread will still
     252 *         succeed, the thread will _not_ terminate properly
     253 *         while PM is locked, so do not wait for such a thread
     254 *         to terminate!! (V0.9.16)
    249255 *
    250256 *      -- THRF_WAIT: if this is set, thrCreate does not
     
    288294 *@@changed V0.9.9 (2001-03-14) [umoeller]: added THRF_WAIT_EXPLICIT
    289295 *@@changed V0.9.12 (2001-05-20) [umoeller]: changed pfRunning to ptidRunning
     296 *@@changed V0.9.16 (2001-10-28) [umoeller]: made ptidRunning volatile to prohibit compiler optimizations
    290297 */
    291298
    292299ULONG thrCreate(PTHREADINFO pti,     // out: THREADINFO data
    293300                PTHREADFUNC pfn,     // in: _Optlink thread function
    294                 PULONG ptidRunning,  // out: variable set to TID while thread is running;
     301                volatile unsigned long *ptidRunning,
     302                                     // out: variable set to TID while thread is running;
    295303                                     // ptr can be NULL
    296304                const char *pcszThreadName, // in: thread name (for identification)
  • trunk/src/helpers/tmsgfile.c

    r113 r116  
    292292                        pNew->cbText = strlen(pStartOfText);
    293293
     294                    // remove trailing newlines
     295                    while (    (pNew->cbText)
     296                            && (pStartOfText[pNew->cbText-1] == '\n')
     297                          )
     298                        (pNew->cbText)--;
     299
    294300                    // store this thing
    295301                    if (!treeInsert(&pFile->IDsTreeRoot,
  • trunk/src/helpers/tree.c

    r113 r116  
    285285 *      initializes the root of a tree.
    286286 *
     287 *      If (plCount != NULL), *plCount is set to null also.
     288 *      This same plCount pointer can then be passed to
     289 *      treeInsert and treeDelete also to automatically
     290 *      maintain a tree item count.
     291 *
    287292 *@@changed V0.9.16 (2001-10-19) [umoeller]: added plCount
    288293 */
     
    509514 *      "x" specifies the new tree node which must
    510515 *      have been allocated by the caller. x->ulKey
    511  *      must already contain the node's key (data).
     516 *      must already contain the node's key (data)
     517 *      which the sort function can understand.
     518 *
    512519 *      This function will then set the parent,
    513  *      left, right, and color members.
     520 *      left, right, and color members. In addition,
     521 *      if (plCount != NULL), *plCount is raised by
     522 *      one.
    514523 *
    515524 *      Returns 0 if no error. Might return
     
    521530
    522531int treeInsert(TREE **root,                     // in: root of the tree
    523                PLONG plCount,                 // in/out: item count (ptr can be NULL)
     532               PLONG plCount,                   // in/out: item count (ptr can be NULL)
    524533               TREE *x,                         // in: new node to insert
    525534               FNTREE_COMPARE *pfnCompare)      // in: comparison func
     
    750759 *      Does not free() the node though.
    751760 *
     761 *      In addition, if (plCount != NULL), *plCount is
     762 *      decremented.
     763 *
    752764 *      Returns 0 if the node was deleted or
    753765 *      STATUS_INVALID_NODE if not.
     
    757769
    758770int treeDelete(TREE **root,         // in: root of the tree
    759                PLONG plCount,     // in/out: item count (ptr can be NULL)
     771               PLONG plCount,       // in/out: item count (ptr can be NULL)
    760772               TREE *tree)          // in: tree node to delete
    761773{
  • trunk/src/helpers/wphandle.c

    r113 r116  
    996996                                         NULL);
    997997
    998                     _Pmpf((__FUNCTION__ ": wphFindPartName returned %d", arc));
     998                    // _Pmpf((__FUNCTION__ ": wphFindPartName returned %d", arc));
    999999                }
    10001000
Note: See TracChangeset for help on using the changeset viewer.