Changeset 110 for trunk/src/helpers/wphandle.c
- Timestamp:
- Oct 15, 2001, 11:17:25 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/wphandle.c
r108 r110 99 99 100 100 APIRET wphQueryActiveHandles(HINI hiniSystem, 101 PSZ *ppszActiveHandles) 101 PSZ *ppszActiveHandles) // out: active handles string (new buffer) 102 102 { 103 103 PSZ pszActiveHandles; … … 231 231 // store PNODE in hash table 232 232 pHandlesBuf->NodeHashTable[pNode->usHandle] = pNode; 233 pCur += sizeof 233 pCur += sizeof(NODE) + pNode->usNameSize; 234 234 } 235 235 else … … 341 341 ULONG cbTotalOld = cbTotal; 342 342 cbTotal += cbBlockThis; 343 if (!(pbData = realloc(pbData, cbTotal)))343 if (!(pbData = (BYTE*)realloc(pbData, cbTotal))) 344 344 // on first call, pbData is NULL and this 345 345 // behaves like malloc() … … 417 417 return (arc); 418 418 } 419 420 /*421 *@@ wphReadAllBlocks:422 * this reads all the BLOCK's in the active handles423 * section in OS2SYS.INI into one common buffer, for424 * which sufficient memory is allocated.425 *426 * Each of these blocks is a maximum of 64 KB, hell427 * knows why, maybe the INIs can't handle more. This428 * func combines all the BLOCK's into one buffer anyways,429 * which can then be searched.430 *431 * Use wphQueryActiveHandles to pass the active handles432 * section to this function.433 *434 * This gets called by the one-shot function435 * wphQueryHandleFromPath.436 */437 438 /* BOOL wphReadAllBlocks(HINI hiniSystem, // in: can be HINI_USER or HINI_SYSTEM439 PSZ pszActiveHandles, // in: active handles section440 PBYTE* ppBlock, // in/out: pointer to buffer, which441 // will point to the allocated442 // memory afterwards443 PULONG pulSize) // out: size of the allocated buffer444 {445 PBYTE pbAllBlocks,446 pszBlockName,447 p;448 ULONG ulBlockSize;449 ULONG ulTotalSize;450 BYTE rgfBlock[100];451 BYTE szAppName[10];452 USHORT usBlockNo;453 454 pbAllBlocks = wphEnumProfileKeys(hiniSystem, pszActiveHandles, &ulBlockSize);455 if (!pbAllBlocks)456 return FALSE;457 458 // query size of all individual blocks and calculate total459 memset(rgfBlock, 0, sizeof rgfBlock);460 ulTotalSize = 0L;461 pszBlockName = pbAllBlocks;462 while (*pszBlockName)463 {464 if (!memicmp(pszBlockName, "BLOCK", 5))465 {466 usBlockNo = atoi(pszBlockName + 5);467 if (usBlockNo < 100)468 {469 rgfBlock[usBlockNo] = TRUE;470 471 if (!PrfQueryProfileSize(hiniSystem,472 pszActiveHandles,473 pszBlockName,474 &ulBlockSize))475 {476 free(pbAllBlocks);477 return FALSE;478 }479 ulTotalSize += ulBlockSize;480 }481 }482 pszBlockName += strlen(pszBlockName) + 1;483 }484 485 // *pulSize now contains the total size of all blocks486 *ppBlock = (PBYTE)malloc(ulTotalSize);487 if (!(*ppBlock))488 {489 free(pbAllBlocks);490 return FALSE;491 }492 493 // now get all blocks into the memory we allocated494 p = *ppBlock;495 (*pulSize) = 0;496 for (usBlockNo = 1; usBlockNo < 100; usBlockNo++)497 {498 if (!rgfBlock[usBlockNo])499 break;500 501 sprintf(szAppName, "BLOCK%u", (UINT)usBlockNo);502 ulBlockSize = ulTotalSize;503 if (!PrfQueryProfileData(hiniSystem,504 pszActiveHandles,505 szAppName,506 p,507 &ulBlockSize))508 {509 free(pbAllBlocks);510 free(*ppBlock);511 return FALSE;512 }513 p += ulBlockSize;514 (*pulSize) += ulBlockSize;515 ulTotalSize -= ulBlockSize;516 }517 518 free(pbAllBlocks);519 return TRUE;520 } */521 419 522 420 /* ****************************************************************** … … 688 586 { 689 587 APIRET arc = NO_ERROR; 690 PVOID pvData; 588 589 PSZ pszActiveHandles = NULL; 590 PHANDLESBUF pHandlesBuf = NULL; 691 591 692 592 TRY_LOUD(excpt1) 693 593 { 694 594 // not found there: check the handles then 695 PSZ pszActiveHandles; 595 696 596 if (arc = wphQueryActiveHandles(hiniSystem, &pszActiveHandles)) 697 597 _Pmpf((__FUNCTION__ ": wphQueryActiveHandles returned %d", arc)); 698 598 else 699 599 { 700 PHANDLESBUF pHandlesBuf;701 600 if (arc = wphLoadHandles(hiniUser, 702 601 hiniSystem, … … 719 618 else 720 619 arc = ERROR_FILE_NOT_FOUND; 721 722 wphFreeHandles(&pHandlesBuf); 723 } 724 725 free(pszActiveHandles); 620 } 726 621 } 727 622 } … … 730 625 arc = ERROR_WPH_CRASHED; 731 626 } END_CATCH(); 627 628 if (pszActiveHandles) 629 free(pszActiveHandles); 630 if (pHandlesBuf) 631 wphFreeHandles(&pHandlesBuf); 732 632 733 633 return (arc);
Note:
See TracChangeset
for help on using the changeset viewer.