Changeset 912 for trunk/dll/inis.c


Ignore:
Timestamp:
Jan 9, 2008, 7:27:26 PM (18 years ago)
Author:
Steven Levine
Message:

Avoid closing INI more times than opened
Add some missing error reporting
Standardize PrfOpenProfile return checks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/inis.c

    r907 r912  
    55
    66  Copyright (c) 1993-98 M. Kimes
    7   Copyright (c) 2004, 2007 Steven H. Levine
     7  Copyright (c) 2004, 2008 Steven H. Levine
    88
    99  01 Aug 04 SHL Rework lstrip/rstrip usage
     
    2121  20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
    2222  16 Nov 07 SHL Ensure fixup buffer sufficiently large
     23  09 Jan 08 SHL Avoid closing INI more times than opened
     24  09 Jan 08 SHL Add some missing error reporting
     25  09 Jan 08 SHL Standardize PrfOpenProfile return checks
    2326
    2427***********************************************************************/
     
    9598  HAB hab2;
    9699  HMQ hmq2;
    97   HINI hini1 = (HINI) 0, hini2 = (HINI) 0;
     100  HINI hini1 = NULLHANDLE;
     101  HINI hini2 = NULLHANDLE;
    98102  PRFPROFILE cprfp;
    99103  CHAR userini[CCHMAXPATH], sysini[CCHMAXPATH];
     
    122126            hini2 = HINI_SYSTEMPROFILE;
    123127        }
    124         if (!hini1)
     128        if (hini1 == NULLHANDLE) {
    125129          hini1 = PrfOpenProfile(hab2, inirec->filename1);
    126         if (!hini2) {
     130          if (hini1 == NULLHANDLE) {
     131            Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
     132                      "PrfOpenProfile failed for %s", inirec->filename1);
     133          }
     134        }
     135        if (hini2 == NULLHANDLE) {
    127136          if (!stricmp(inirec->filename1, inirec->filename2))
    128137            hini2 = hini1;
    129           else
     138          else {
    130139            hini2 = PrfOpenProfile(hab2, inirec->filename2);
     140            if (hini2 == NULLHANDLE) {
     141              Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
     142                        "PrfOpenProfile failed for %s", inirec->filename2);
     143            }
     144          }
    131145        }
    132146        if (hini1 && hini2 && (*inirec->app2 || hini1 != hini2)) {
     
    243257        if (hini1)
    244258          PrfCloseProfile(hini1);
    245         if (hini2)
     259        if (hini2 && hini2 != hini1)
    246260          PrfCloseProfile(hini2);
    247261        WinDestroyMsgQueue(hmq2);
     
    290304  HAB hab2;
    291305  HMQ hmq2;
    292   HINI orig = (HINI) 0, new;
     306  HINI orig = NULLHANDLE;
     307  HINI new;
    293308  PVOID pDataA, pDataK, pData;
    294309  PBYTE pCurrentA, pCurrentK;
     
    316331            orig = HINI_SYSTEMPROFILE;
    317332        }
    318         if (!orig)
     333        if (orig == NULLHANDLE)
    319334          orig = PrfOpenProfile(hab2, prfp->pszUserName);
    320         if (orig) {
     335        if (orig == NULLHANDLE) {
     336          Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
     337                    "PrfOpenProfile failed for %s", prfp->pszUserName);
     338        }
     339        else {
    321340          new = PrfOpenProfile(hab2, prfp->pszSysName);
    322           if (new) {
     341          if (new == NULLHANDLE) {
     342            Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
     343                      "PrfOpenProfile failed for %s", prfp->pszSysName);
     344          }
     345          else {
    323346            if (PrfQueryProfileSize(orig, NULL, NULL, (PULONG) & ulSize)
    324347                && ulSize) {
     
    921944        WinQueryDlgItemText(hwnd, INIR_SYSTEMPROFILE, CCHMAXPATH, sysini);
    922945        testini = PrfOpenProfile(WinQueryAnchorBlock(hwnd), userini);
    923         if (!testini) {
     946        if (testini == NULLHANDLE) {
    924947          saymsg(MB_CANCEL,
    925948                 hwnd,
     
    930953        PrfCloseProfile(testini);
    931954        testini = PrfOpenProfile(WinQueryAnchorBlock(hwnd), sysini);
    932         if (!testini) {
     955        if (testini == NULLHANDLE) {
    933956          saymsg(MB_CANCEL,
    934957                 hwnd,
     
    10541077        MakeFullName(sysini);
    10551078        testini = PrfOpenProfile(WinQueryAnchorBlock(hwnd), userini);
    1056         if (!testini) {
     1079        if (testini == NULLHANDLE) {
    10571080          saymsg(MB_CANCEL,
    10581081                 hwnd,
     
    10631086        PrfCloseProfile(testini);
    10641087        testini = PrfOpenProfile(WinQueryAnchorBlock(hwnd), sysini);
    1065         if (!testini) {
     1088        if (testini == NULLHANDLE) {
    10661089          saymsg(MB_CANCEL,
    10671090                 hwnd,
     
    14301453      return (HWND) 0;
    14311454    hINI = PrfOpenProfile(useHab, filename);
    1432     if (!hINI) {
     1455    if (hINI == NULLHANDLE) {
    14331456      free(filename);
    14341457      return (HWND) 0;
     
    19792002      else
    19802003        inidata->hini = HINI_USERPROFILE;
    1981       if (!inidata->hini) {
     2004      if (inidata->hini == NULLHANDLE) {
     2005        Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
     2006                  "PrfOpenProfile failed for %s", inidata->ininame);
    19822007        PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
    19832008        break;
     
    25152540            !DosQueryPathInfo(filename, FIL_STANDARD, &fsa, sizeof(fsa))) {
    25162541          hINI = PrfOpenProfile(WinQueryAnchorBlock(hwnd), filename);
    2517           if (!hINI) {
     2542          if (hINI == NULLHANDLE) {
    25182543            Win_Error(hwnd, hwnd, __FILE__, __LINE__,
    25192544                      GetPString(IDS_INICANTOPENINITEXT), filename);
Note: See TracChangeset for help on using the changeset viewer.