Ignore:
Timestamp:
Dec 18, 2011, 10:28:22 PM (14 years ago)
Author:
dmik
Message:

Merge branch gcc-kmk to trunk.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        1 bin
        2 Makefile.inc
         1env.cmd
         2LocalConfig.kmk
    • Property svn:mergeinfo set to
      /branches/gcc-kmkmergedeligible
  • trunk/src/kernel32/handlenames.cpp

    r21302 r21916  
    2727#define INCL_DOSSEMAPHORES
    2828#define INCL_DOSERRORS
    29 #include <os2.h>
     29#include <os2wrap.h>
    3030
    3131#include <stdlib.h>
     
    5353  PSZ   pszTarget;
    5454  ULONG ulTargetLength;
    55  
     55
    5656  // the alias prefix
    5757  PSZ   pszSymbolicLink;
     
    6565    VMutex       mtxHandleNameMgr;
    6666    CLinearList* pSymbolicLinks;
    67  
    68     PHANDLENAME findSymbolicLink(PSZ pszSymbolicLink,
     67
     68    PHANDLENAME findSymbolicLink(PCSZ pszSymbolicLink,
    6969                                 BOOL fCaseInsensitive);
    70  
    71     PHANDLENAME findSymbolicLinkExact(PSZ pszSymbolicLink);
    72  
     70
     71    PHANDLENAME findSymbolicLinkExact(PCSZ pszSymbolicLink);
     72
    7373  public:
    7474    HandleNames(void);
    7575    ~HandleNames();
    76  
    77     BOOL addSymbolicLink(PSZ pszSymbolicLink,
    78                          PSZ pszTarget);
    79  
    80     BOOL removeSymbolicLink(PSZ pszSymbolicLink);
    81  
    82     BOOL removeTarget(PSZ pszTarget);
    83  
    84     BOOL resolveName(PSZ pszName,
    85                      PSZ pszTarget, 
    86                      ULONG ulTargetLength, 
     76
     77    BOOL addSymbolicLink(PCSZ pszSymbolicLink,
     78                         PCSZ pszTarget);
     79
     80    BOOL removeSymbolicLink(PCSZ pszSymbolicLink);
     81
     82    BOOL removeTarget(PCSZ pszTarget);
     83
     84    BOOL resolveName(PCSZ pszName,
     85                     PSZ pszTarget,
     86                     ULONG ulTargetLength,
    8787                     BOOL fCaseInsensitive);
    8888};
     
    107107 * Name      : HandleNames::HandleNames
    108108 * Purpose   : Constructor for handle name mapper
    109  * Parameters: 
    110  * Variables :
    111  * Result    : 
     109 * Parameters:
     110 * Variables :
     111 * Result    :
    112112 * Remark    :
    113113 * Status    :
     
    127127 * Name      : HandleNames::~HandleNames
    128128 * Purpose   : destructor for handle name mapper
    129  * Parameters: 
    130  * Variables :
    131  * Result    : 
     129 * Parameters:
     130 * Variables :
     131 * Result    :
    132132 * Remark    :
    133133 * Status    :
     
    148148 *             BOOL fCaseInsensitive - TRUE for a case-insensitive lookup
    149149 * Variables :
    150  * Result    : 
     150 * Result    :
    151151 * Remark    : The comparison here is not meant to be "identity" but
    152152 *             "startsWith" because for the name resolver, the first
     
    161161 *****************************************************************************/
    162162
    163 PHANDLENAME HandleNames::findSymbolicLink(PSZ pszSymbolicLink,
     163PHANDLENAME HandleNames::findSymbolicLink(PCSZ pszSymbolicLink,
    164164                                          BOOL fCaseInsensitive)
    165165{
     
    170170    PHANDLENAME pHandleName = (PHANDLENAME)pLE->pObject;
    171171    int cch = pHandleName->ulSymbolicLinkLength; //strlen(pHandleName->pszSymbolicLink);
    172    
     172
    173173    /* pszSymbolicLink must end a path component at cch. */
    174174    if (    cch <= cchSymbolicLink
     
    186186    }
    187187    }
    188    
     188
    189189    // skip to the next entry
    190190    pLE = pSymbolicLinks->getNext(pLE);
    191191  }
    192  
     192
    193193  // not found
    194194  return NULL;
     
    202202 *             BOOL fCaseInsensitive - TRUE for a case-insensitive lookup
    203203 * Variables :
    204  * Result    : 
     204 * Result    :
    205205 * Remark    : The comparison here is not meant to be "identity" but
    206206 *             "startsWith" because for the name resolver, the first
     
    215215 *****************************************************************************/
    216216
    217 PHANDLENAME HandleNames::findSymbolicLinkExact(PSZ pszSymbolicLink)
     217PHANDLENAME HandleNames::findSymbolicLinkExact(PCSZ pszSymbolicLink)
    218218{
    219219  PLINEARLISTENTRY pLE = pSymbolicLinks->getFirst();
     
    221221  {
    222222    PHANDLENAME pHandleName = (PHANDLENAME)pLE->pObject;
    223    
     223
    224224    if (strcmp(pHandleName->pszSymbolicLink, pszSymbolicLink) == 0)
    225225      return pHandleName;
    226    
     226
    227227    // skip to the next entry
    228228    pLE = pSymbolicLinks->getNext(pLE);
    229229  }
    230  
     230
    231231  // not found
    232232  return NULL;
     
    248248 *****************************************************************************/
    249249
    250 BOOL HandleNames::addSymbolicLink(PSZ pszSymbolicLink,
    251                                   PSZ pszTarget)
     250BOOL HandleNames::addSymbolicLink(PCSZ pszSymbolicLink,
     251                                  PCSZ pszTarget)
    252252{
    253253  BOOL rc = TRUE;
    254  
     254
    255255  mtxHandleNameMgr.enter();
    256  
     256
    257257  // 1 - find symbolic link with same name
    258258  PHANDLENAME pHandleName = findSymbolicLinkExact(pszSymbolicLink);
    259  
    260   // 2 - if found 
     259
     260  // 2 - if found
    261261  if (NULL != pHandleName)
    262262  {
     
    264264    if (strcmp(pszTarget, pHandleName->pszTarget) == 0)
    265265      rc = TRUE;
    266    
     266
    267267    // 2.2 - and targets are identical, return TRUE
    268268    else
     
    297297          pHandleName->ulTargetLength = strlen(pszTarget);
    298298          pHandleName->ulSymbolicLinkLength = strlen(pszSymbolicLink);
    299          
     299
    300300          // OK, finally add to the list
    301301          pSymbolicLinks->addFirst(pHandleName);
     
    304304    }
    305305  }
    306  
     306
    307307  mtxHandleNameMgr.leave();
    308  
     308
    309309  return rc;
    310310}
     
    312312
    313313/*****************************************************************************
    314  * Name      : 
    315  * Purpose   : 
    316  * Parameters: 
     314 * Name      :
     315 * Purpose   :
     316 * Parameters:
    317317 * Variables :
    318318 * Result    : TRUE if successful, FALSE if otherwise
     
    323323 *****************************************************************************/
    324324
    325 BOOL HandleNames::removeSymbolicLink(PSZ pszSymbolicLink)
     325BOOL HandleNames::removeSymbolicLink(PCSZ pszSymbolicLink)
    326326{
    327327  BOOL rc = TRUE;
    328  
     328
    329329  mtxHandleNameMgr.enter();
    330  
     330
    331331  // 1 - find symbolic name
    332332  PHANDLENAME pHandleName = findSymbolicLinkExact(pszSymbolicLink);
     
    337337    // 2 - remove the link
    338338    pSymbolicLinks->removeObject(pHandleName);
    339    
     339
    340340    if (NULL != pHandleName->pszSymbolicLink )
    341341      free( pHandleName->pszSymbolicLink );
    342    
     342
    343343    if (NULL != pHandleName->pszTarget )
    344344      free( pHandleName->pszTarget );
    345    
     345
    346346    free( pHandleName );
    347347  }
    348  
     348
    349349  mtxHandleNameMgr.leave();
    350  
     350
    351351  return rc;
    352352}
     
    365365 *****************************************************************************/
    366366
    367 BOOL HandleNames::removeTarget(PSZ pszTarget)
     367BOOL HandleNames::removeTarget(PCSZ pszTarget)
    368368{
    369369  BOOL rc = FALSE;
    370  
     370
    371371  mtxHandleNameMgr.enter();
    372  
     372
    373373  // iterate over all registered symbolic links
    374374  PLINEARLISTENTRY pLE = pSymbolicLinks->getFirst();
     
    376376  {
    377377    PHANDLENAME pHandleName = (PHANDLENAME)pLE->pObject;
    378    
     378
    379379    // check the name
    380380    if (strcmp(pszTarget, pHandleName->pszTarget) == 0)
    381381    {
    382382      pSymbolicLinks->removeElement(pLE);
    383      
     383
    384384      // at least one removal succeeded
    385385      rc = TRUE;
    386386    }
    387387  }
    388  
     388
    389389  mtxHandleNameMgr.leave();
    390  
     390
    391391  return rc;
    392392}
     
    403403 * Variables :
    404404 * Result    : FALSE if name was not modified, TRUE if name was resolved
    405  * Remark    : This is a very easy, cheesy implementation of a pathname 
     405 * Remark    : This is a very easy, cheesy implementation of a pathname
    406406 *             cracker. Should be sufficient at the moment though.
    407407 * Status    :
     
    410410 *****************************************************************************/
    411411
    412 BOOL HandleNames::resolveName(PSZ pszName,
    413                               PSZ pszTarget, 
     412BOOL HandleNames::resolveName(PCSZ pszName,
     413                              PSZ pszTarget,
    414414                              ULONG ulTargetLength,
    415415                              BOOL fCaseInsensitive)
    416416{
    417417  BOOL rc = FALSE;
    418  
     418
    419419  mtxHandleNameMgr.enter();
    420  
     420
    421421  // scan through the names (case-insensitive)
    422422  PHANDLENAME pHandleName = findSymbolicLink(pszName, fCaseInsensitive);
     
    425425    // rebuild the target name
    426426    int iNameLength     = strlen(pszName);
    427    
     427
    428428    // first copy the resolved target name fragment
    429429    strncpy(pszTarget,
    430430            pHandleName->pszTarget,
    431431            ulTargetLength);
    432    
     432
    433433    // now append the rest of the specified name with the
    434434    // now resolved symbolic cut away
     
    437437              pszName + pHandleName->ulSymbolicLinkLength,
    438438              ulTargetLength - pHandleName->ulTargetLength);
    439    
     439
    440440    // tell caller the name has been resolved
    441441    // (is different from the source name)
    442442    rc = TRUE;
    443443  }
    444  
     444
    445445  mtxHandleNameMgr.leave();
    446  
     446
    447447  return rc;
    448448}
     
    454454 * Exported Wrapper Functions
    455455 *****************************************************************************/
    456  
    457 BOOL HandleNamesResolveName(PSZ pszName,
     456
     457BOOL HandleNamesResolveName(PCSZ pszName,
    458458                            PSZ pszTarget,
    459459                            ULONG ulTargetLength,
     
    467467
    468468
    469 BOOL HandleNamesAddSymbolicLink(PSZ pszSymbolicLink,
    470                                 PSZ pszTarget)
     469BOOL HandleNamesAddSymbolicLink(PCSZ pszSymbolicLink,
     470                                PCSZ pszTarget)
    471471{
    472472  return pHandleNameMgr->addSymbolicLink(pszSymbolicLink,
    473473                                         pszTarget);
    474474}
    475  
    476 
    477 BOOL HandleNamesRemoveSymbolicLink(PSZ pszSymbolicLink)
     475
     476
     477BOOL HandleNamesRemoveSymbolicLink(PCSZ pszSymbolicLink)
    478478{
    479479  return pHandleNameMgr->removeSymbolicLink(pszSymbolicLink);
    480480}
    481  
    482 
    483 BOOL HandleNamesRemoveTarget(PSZ pszTarget)
     481
     482
     483BOOL HandleNamesRemoveTarget(PCSZ pszTarget)
    484484{
    485485  return pHandleNameMgr->removeTarget(pszTarget);
Note: See TracChangeset for help on using the changeset viewer.