Changeset 240 for trunk/src/helpers


Ignore:
Timestamp:
Jan 12, 2003, 11:49:24 AM (23 years ago)
Author:
umoeller
Message:

Misc fixes.

Location:
trunk/src/helpers
Files:
6 edited

Legend:

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

    r238 r240  
    16571657       )
    16581658    {
    1659         CHAR szTemp[30] = "?:\\long.name.file";
     1659        CHAR szTemp[] = "?:\\long.name.file";
    16601660        szTemp[0]  = ulLogicalDrive + 'A' - 1;
    16611661        if (!(arc = DosOpen(szTemp,
     
    40144014 +      PDOSHPERFSYS pPerf = NULL;
    40154015 +      APIRET arc;
    4016  +      if (!(arc = arc = doshPerfOpen(&pPerf)))
     4016 +      if (!(arc = doshPerfOpen(&pPerf)))
    40174017 +      {
    40184018 +          // this should really be in a timer,
     
    40434043
    40444044    // allocate DOSHPERFSYS structure
    4045     *ppPerfSys = (PDOSHPERFSYS)malloc(sizeof(DOSHPERFSYS));
    4046     if (!*ppPerfSys)
     4045    if (!(*ppPerfSys = (PDOSHPERFSYS)malloc(sizeof(DOSHPERFSYS))))
    40474046        arc = ERROR_NOT_ENOUGH_MEMORY;
    40484047    else
  • trunk/src/helpers/dosh2.c

    r238 r240  
    383383    }
    384384
    385     return(ERROR_BUFFER_OVERFLOW);
     385    return ERROR_BUFFER_OVERFLOW;
    386386}
    387387
     
    607607    {
    608608        // try additional things then
    609         PSZ psz2 = (PSZ)malloc(strlen(pcszCommand) + 20);
    610         if (psz2)
     609        PSZ psz2;
     610        if (psz2 = (PSZ)malloc(strlen(pcszCommand) + 20))
    611611        {
    612612            ULONG   ul;
  • trunk/src/helpers/exeh.c

    r236 r240  
    257257                              &cbFile,
    258258                              &pFile)))
    259             // file opened successfully:
    260259       )
    261260    {
     261        // file opened successfully:
    262262        pExec->pFile = pFile;
    263263        pExec->cbDosExeHeader = sizeof(DOSEXEHEADER);
     
    505505    } // end if (fLoadNewHeader)
    506506
    507     if (arc != NO_ERROR)
     507    if (arc)
    508508        // error: clean up
    509509        exehClose(&pExec);
  • trunk/src/helpers/gpih.c

    r238 r240  
    28072807 *
    28082808 *      This function may relieve this a bit. This
    2809  *      creates a memory DC, an memory PS, and a bitmap,
     2809 *      creates a memory DC, a memory PS, and a bitmap,
    28102810 *      and selects the bitmap into the memory PS.
    28112811 *      You can then use any GPI function on the memory
     
    28202820 *      Example:
    28212821 *
    2822  +          PXBITMAP pbmp = gpihCreateXBitmap(hab, 100, 100);
    2823  +          if (pbmp)
     2822 +          PXBITMAP pbmp;
     2823 +          if (pbmp = gpihCreateXBitmap(hab, 100, 100))
    28242824 +          {
    28252825 +              GpiMove(pbmp->hpsMem, ...);
     
    28452845{
    28462846    BOOL fOK = FALSE;
    2847     PXBITMAP pbmp = (PXBITMAP)malloc(sizeof(XBITMAP));
    2848     if (pbmp)
     2847    PXBITMAP pbmp;
     2848    if (pbmp = (PXBITMAP)malloc(sizeof(XBITMAP)))
    28492849    {
    28502850        memset(pbmp, 0, sizeof(XBITMAP));
  • trunk/src/helpers/procstat.c

    r238 r240  
    497497
    498498/*
     499 *@@ prc32GetInfo2:
     500 *      nifty interface to DosQuerySysState, the 32-bit
     501 *      version of DosQProcStat.
     502 *
     503 *      This returns the head of a newly allocated buffer
     504 *      which has plenty of pointers for subsequent browing.
     505 *
     506 *      As opposed to prc32GetInfo, with this call you can
     507 *      specify the information that would like to retrieve.
     508 *
     509 *      Use prc32FreeInfo to free the buffer.
     510 *
     511 *@@added V1.0.1 (2003-01-10) [umoeller]
     512 */
     513
     514PQTOPLEVEL32 prc32GetInfo2(ULONG fl,        // in: QS32_* flags
     515                           APIRET *parc)    // out: error, ptr can be NULL
     516{
     517    APIRET          arc;
     518    PQTOPLEVEL32    pReturn = NULL;
     519
     520    #define BUFSIZE (1024 * 1024) // 1 meg
     521
     522    if (!(arc = DosAllocMem((PVOID*)&pReturn,
     523                            BUFSIZE,
     524                            PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_TILE)))
     525    {
     526        if (arc = DosQuerySysState(fl,
     527                                   fl,      // this was missing V0.9.10 (2001-04-08) [umoeller]
     528                                   0, 0,
     529                                   (PCHAR)pReturn,
     530                                   BUFSIZE))
     531        {
     532            DosFreeMem(pReturn);
     533            pReturn = NULL;
     534        }
     535    }
     536
     537    if (parc)
     538        *parc = arc;
     539
     540    return pReturn;
     541}
     542
     543/*
    499544 *@@ prc32GetInfo:
    500  *      nifty interface to DosQuerySysState,
    501  *      the 32-bit version of DosQProcStat.
    502  *      This returns the head of a newly
    503  *      allocated buffer which has plenty
    504  *      of pointers for subsequent browing.
     545 *      nifty interface to DosQuerySysState, the 32-bit
     546 *      version of DosQProcStat.
     547 *
     548 *      This returns the head of a newly allocated buffer
     549 *      which has plenty of pointers for subsequent browing.
    505550 *
    506551 *      Use prc32FreeInfo to free the buffer.
     
    513558PQTOPLEVEL32 prc32GetInfo(APIRET *parc)     // out: error, ptr can be NULL
    514559{
    515     #define BUFSIZE (1024 * 1024) // 1 meg
    516 
    517     PCHAR pBuf = NULL; // (PCHAR)malloc(BUFSIZE);
    518 
    519     if (DosAllocMem((PVOID*)&pBuf,
    520                     BUFSIZE,
    521                     PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_TILE)
    522             == NO_ERROR)
    523         if (pBuf)
    524         {
    525             APIRET arc = DosQuerySysState(QS32_SUPPORTED,
    526                                           QS32_SUPPORTED,       // this was missing
    527                                                                 // V0.9.10 (2001-04-08) [umoeller]
    528                                           0, 0,
    529                                           (PCHAR)pBuf,
    530                                           BUFSIZE);
    531             if (parc)
    532                 *parc = arc;
    533 
    534             if (arc == NO_ERROR)
    535                 return (PQTOPLEVEL32)pBuf;
    536             else
    537                 DosFreeMem(pBuf);
    538         }
    539 
    540     return NULL;
     560    return prc32GetInfo2(QS32_SUPPORTED,
     561                         parc);
    541562}
    542563
  • trunk/src/helpers/stringh.c

    r238 r240  
    178178    *string1 = '\0';
    179179    return string1;
     180}
     181
     182/*
     183 *@@ strhCopyBuf:
     184 *      copies pcszSource to pszTarget, taking
     185 *      its length into account.
     186 *
     187 *      Returns:
     188 *
     189 *      --  NO_ERROR
     190 *
     191 *      --  ERROR_INVALID_PARAMETER: pcszSource is
     192 *          null or points to a null byte.
     193 *
     194 *      --  ERROR_FILENAME_EXCED_RANGE: pcszSource
     195 *          is too long to fit into pszTarget.
     196 *
     197 *@@added V1.0.1 (2003-01-05) [umoeller]
     198 */
     199
     200APIRET strhCopyBuf(PSZ pszTarget,
     201                   PCSZ pcszSource,
     202                   ULONG cbTarget)
     203{
     204    ULONG cb;
     205    if (!pcszSource || !*pcszSource)
     206        return ERROR_INVALID_PARAMETER;
     207    cb = strlen(pcszSource) + 1;
     208    if (cb > cbTarget)
     209        return ERROR_FILENAME_EXCED_RANGE;
     210
     211    memcpy(pszTarget,
     212           pcszSource,
     213           cb);
     214    return NO_ERROR;
    180215}
    181216
Note: See TracChangeset for help on using the changeset viewer.