Changeset 352
- Timestamp:
- Jul 26, 2006, 9:35:45 PM (19 years ago)
- Location:
- trunk/dll
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/collect.c
r280 r352 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2003, 200 5Steven H. Levine9 Copyright (c) 2003, 2006 Steven H. Levine 10 10 11 11 15 Oct 02 MK Baseline … … 22 22 24 Oct 05 SHL CollectorCnrWndProc: avoid excess writes to Status2 window 23 23 10 Nov 05 SHL CollectorCnrWndProc: correct missing button window updates 24 14 Jul 06 SHL Use Runtime_Error 24 25 25 26 ***********************************************************************/ … … 48 49 49 50 #pragma data_seg(DATA1) 51 52 static PSZ pszSrcFile = __FILE__; 53 50 54 #pragma alloc_text(COLLECTOR,CollectorCnrWndProc,CollectorObjWndProc) 51 55 #pragma alloc_text(COLLECTOR,CollectorClientWndProc,CollectorTextProc) … … 113 117 id); 114 118 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd, 115 QW_PARENT),119 QW_PARENT), 116 120 COLLECTOR_CNR), 117 121 QWL_USER); … … 631 635 DIR_SELECTED), 632 636 GetPString(IDS_COLLECTINGTEXT)); 633 for (x = 0; li -> list[x]; x++) 634 { 635 ; 636 } 637 ulMaxFiles = x; 638 if (ulMaxFiles) 639 { 637 for (ulMaxFiles = 0; li -> list[ulMaxFiles]; ulMaxFiles++) 638 ; // Count 639 640 if (ulMaxFiles) { 640 641 pci = WinSendMsg(dcd -> hwndCnr, CM_ALLOCRECORD, 641 642 MPFROMLONG(EXTRA_RECORD_BYTES), 642 643 MPFROMLONG(ulMaxFiles)); 643 if (pci) 644 { 644 if (pci) { 645 Runtime_Error(pszSrcFile, __LINE__, "CM_ALLOCRECORD %u failed", ulMaxFiles); 646 break; 647 } 648 else { 645 649 pciFirst = pci; 646 650 for (x = 0; li -> list[x]; x++) … … 933 937 WORKER *wk; 934 938 935 wk = malloc(sizeof(WORKER)); 936 if (wk) 937 { 938 memset(wk, 0, sizeof(WORKER)); 939 wk = xmallocz(sizeof(WORKER),pszSrcFile,__LINE__); 940 if (!wk) { 941 FreeListInfo((LISTINFO *) mp1); 942 } 943 else { 939 944 wk -> size = sizeof(WORKER); 940 945 wk -> hwndCnr = dcd -> hwndCnr; … … 946 951 if (_beginthread(MassAction, NULL, 122880, (PVOID) wk) == -1) 947 952 { 953 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT)); 948 954 free(wk); 949 955 FreeListInfo((LISTINFO *) mp1); 950 956 } 951 957 } 952 else953 FreeListInfo((LISTINFO *) mp1);954 958 } 955 959 } … … 964 968 WORKER *wk; 965 969 966 wk = malloc(sizeof(WORKER));967 if ( wk)968 {969 memset(wk, 0, sizeof(WORKER));970 wk = xmallocz(sizeof(WORKER),pszSrcFile,__LINE__); 971 if (!wk) 972 FreeListInfo((LISTINFO *) mp1); 973 else { 970 974 wk -> size = sizeof(WORKER); 971 975 wk -> hwndCnr = dcd -> hwndCnr; … … 977 981 if (_beginthread(Action, NULL, 122880, (PVOID) wk) == -1) 978 982 { 983 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT)); 979 984 free(wk); 980 985 FreeListInfo((LISTINFO *) mp1); 981 986 } 982 987 } 983 else984 FreeListInfo((LISTINFO *) mp1);985 988 } 986 989 } … … 1158 1161 if (!IsFile(leftdir) && !IsFile(rightdir)) 1159 1162 { 1160 cmp = malloc(sizeof(COMPARE));1163 cmp = xmallocz(sizeof(COMPARE),pszSrcFile,__LINE__); 1161 1164 if (cmp) 1162 1165 { 1163 memset(cmp, 0, sizeof(COMPARE));1164 1166 cmp -> size = sizeof(COMPARE); 1165 1167 strcpy(cmp -> leftdir, leftdir); … … 1350 1352 1351 1353 case UM_CONTAINER_FILLED: 1352 DosBeep(1000, 50); 1354 DosBeep(1000, 50); // fixme to know why beep here 1353 1355 WinSendMsg(hwnd, 1354 1356 CM_INVALIDATERECORD, … … 1469 1471 if (_beginthread(MakeObjWin, NULL, 245760, (PVOID) dcd) == -1) 1470 1472 { 1473 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT)); 1471 1474 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID); 1472 1475 return 0; … … 1584 1587 if (!PostMsg(dcd -> hwndObject, UM_COLLECTFROMFILE, mp1, mp2)) 1585 1588 { 1589 Runtime_Error(pszSrcFile, __LINE__, "PostMsg"); 1586 1590 free(mp1); 1587 DosBeep(50, 100);1588 1591 } 1589 1592 } … … 1602 1605 if (!PostMsg(dcd -> hwndObject, UM_COMMAND, mp1, mp2)) 1603 1606 { 1607 Runtime_Error(pszSrcFile, __LINE__, "PostMsg"); 1604 1608 FreeListInfo((LISTINFO *) mp1); 1605 DosBeep(50, 100);1606 1609 } 1607 1610 else … … 1720 1723 if (insert_filename(hwnd, filename, FALSE, FALSE)) 1721 1724 { 1722 p = strdup(filename);1725 p = xstrdup(filename,pszSrcFile,__LINE__); 1723 1726 if (p) 1724 1727 { … … 1838 1841 LISTINFO *li; 1839 1842 1840 li = malloc(sizeof(LISTINFO));1843 li = xmallocz(sizeof(LISTINFO),pszSrcFile,__LINE__); 1841 1844 if (li) 1842 1845 { 1843 memset(li, 0, sizeof(LISTINFO));1844 1846 li -> list = ListFromClipboard(hwnd); 1845 1847 if (!li -> list || !li -> list[0]) … … 1909 1911 LISTINFO *li; 1910 1912 1911 li = malloc(sizeof(LISTINFO));1913 li = xmallocz(sizeof(LISTINFO),pszSrcFile,__LINE__); 1912 1914 if (li) 1913 1915 { 1914 memset(li, 0, sizeof(LISTINFO));1915 1916 li -> list = mp2; 1916 1917 if (!li -> list || !li -> list[0]) … … 1946 1947 1947 1948 case IDM_GREP: 1948 if (!dcd -> amextracted) 1949 if (dcd -> amextracted) { 1950 // fixme to disable? 1951 Runtime_Error(pszSrcFile, __LINE__, "busy"); 1952 } 1953 else 1949 1954 { 1950 1955 if (WinDlgBox(HWND_DESKTOP, hwnd, GrepDlgProc, … … 1961 1966 } 1962 1967 } 1963 else1964 DosBeep(50, 100); // Complain about busy1965 1968 break; 1966 1969 … … 2221 2224 ULONG action = UM_ACTION; 2222 2225 2223 li = malloc(sizeof(LISTINFO));2226 li = xmallocz(sizeof(LISTINFO),pszSrcFile,__LINE__); 2224 2227 if (li) 2225 2228 { 2226 memset(li, 0, sizeof(LISTINFO));2227 2229 li -> type = SHORT1FROMMP(mp1); 2228 2230 li -> hwnd = hwnd; … … 2263 2265 MPVOID)) 2264 2266 { 2267 Runtime_Error(pszSrcFile, __LINE__, "PostMsg"); 2265 2268 FreeListInfo(li); 2266 DosBeep(50, 100);2267 2269 } 2268 2270 else if (fUnHilite) … … 2385 2387 if (!DrgAccessDraginfo(pDInfo)) 2386 2388 { 2387 Win_Error(hwnd, hwnd, __FILE__, __LINE__,2389 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, 2388 2390 "%s", 2389 2391 GetPString(IDS_DROPERRORTEXT)); … … 3000 3002 id = COLLECTOR_FRAME + idinc++; 3001 3003 WinSetWindowUShort(hwndFrame, QWS_ID, id); 3002 dcd = malloc(sizeof(DIRCNRDATA)); 3003 if (dcd) 3004 { 3005 memset(dcd, 0, sizeof(DIRCNRDATA)); 3004 dcd = xmallocz(sizeof(DIRCNRDATA),pszSrcFile,__LINE__); 3005 if (dcd) { 3006 3006 dcd -> size = sizeof(DIRCNRDATA); 3007 3007 dcd -> id = id; -
trunk/dll/mainwnd.c
r297 r352 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2001, 200 5Steven H. Levine9 Copyright (c) 2001, 2006 Steven H. Levine 10 10 11 11 11 Jun 02 SHL Drop obsolete xor code … … 22 22 17 Dec 05 SHL DriveProc: correct my stupid 23 23 29 May 06 SHL IDM_EDITANYARCHIVER: sanitize code 24 17 Jul 06 SHL Use Runtime_Error 24 25 25 26 ***********************************************************************/ … … 46 47 47 48 #pragma data_seg(DATA1) 49 50 static PSZ pszSrcFile = __FILE__; 51 48 52 #pragma alloc_text(MISC8,SetToggleChecks,FindDirCnrByName,TopWindow) 49 53 #pragma alloc_text(MISC8,TopWindowName,CountDirCnrs) … … 499 503 tool = tool -> next; 500 504 /* allocate swp array for WinSetMultWindowPos */ 501 swp = malloc(sizeof(SWP) * (numtools + 2)); 502 if (swp) 503 { 504 memset(swp, 0, sizeof(SWP) * (numtools + 2)); 505 for (x = 0; x < numtools + 2L; x++) 506 { 505 swp = xmallocz(sizeof(SWP) * (numtools + 2),pszSrcFile,__LINE__); 506 if (swp) { 507 for (x = 0; x < numtools + 2L; x++) { 507 508 swp[x].hwndInsertBehind = HWND_TOP; 508 509 swp[x].fl = attrib; … … 1003 1004 if (tlen) 1004 1005 { 1005 s = malloc(tlen + 2); 1006 if (s) 1007 { 1006 s = xmalloc(tlen + 2,pszSrcFile,__LINE__); 1007 if (s) { 1008 1008 WinQueryWindowText(hwnd, tlen + 1, s); 1009 if (*s) 1010 { 1009 if (*s) { 1011 1010 p = s; 1012 1011 y = swp.cy - 3; … … 4923 4922 COMPARE *cmp; 4924 4923 4925 cmp = malloc(sizeof(COMPARE)); 4926 if (cmp) 4927 { 4928 memset(cmp, 0, sizeof(COMPARE)); 4924 cmp = xmallocz(sizeof(COMPARE),pszSrcFile,__LINE__); 4925 if (cmp) { 4929 4926 cmp -> size = sizeof(COMPARE); 4930 4927 strcpy(cmp -> leftdir, wa.szCurrentPath1); … … 5004 5001 if (SHORT1FROMMP(mp1) == IDM_ADDTOUSERLIST) 5005 5002 { 5006 if (add_udir(TRUE, path)) 5007 { 5003 if (!add_udir(TRUE, path)) 5004 Runtime_Error(pszSrcFile, __LINE__, "add_udir"); 5005 else { 5008 5006 if (fUdirsChanged) 5009 5007 save_udirs(); … … 5013 5011 MPVOID); 5014 5012 } 5015 else5016 DosBeep(50, 50);5017 5013 } 5018 5014 else 5019 5015 { 5020 if (remove_udir(path)) 5021 { 5016 if (!remove_udir(path)) 5017 Runtime_Error(pszSrcFile, __LINE__, "remove_udir"); 5018 else { 5022 5019 if (fUdirsChanged) 5023 5020 save_udirs(); 5024 5021 WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID); 5025 5022 } 5026 else5027 DosBeep(50, 50);5028 5023 } 5029 5024 } … … 5066 5061 sprintf(s, "%s.NumDirsLastTime", name); 5067 5062 size = sizeof(ULONG); 5068 if (PrfQueryProfileData(fmprof, FM3Str, s, (PVOID) & numsaves, 5069 &size) && size) 5070 { 5063 if (!PrfQueryProfileData(fmprof, FM3Str, s, (PVOID)&numsaves, &size)) 5064 Win_Error(hwnd,hwnd,__FILE__,__LINE__,"PrfQueryProfileData"); 5065 else if (!size) 5066 Runtime_Error(pszSrcFile, __LINE__, "no data"); 5067 else { 5071 5068 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L); 5072 5069 for (x = 0; x < numsaves; x++) … … 5088 5085 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0); 5089 5086 } 5090 else5091 DosBeep(50, 100);5092 5087 PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID); 5093 5088 } … … 5765 5760 MPVOID, 5766 5761 MPVOID); 5767 if (!hwndCnr) 5768 { 5769 DosBeep(50, 100); 5762 if (!hwndCnr) { 5763 Runtime_Error(pszSrcFile, __LINE__, "no window"); 5770 5764 break; 5771 5765 } … … 5855 5849 WinSetWindowUShort(hwnd, QWL_USER + 12, 0); 5856 5850 WinSetWindowUShort(hwnd, QWL_USER + 16, 0); 5857 if (_beginthread(MakeMainObjWin, 5858 NULL, 5859 245760, 5860 MPVOID) == -1) 5861 { 5862 PostMsg(hwnd, 5863 WM_CLOSE, 5864 MPVOID, 5865 MPVOID); 5851 if (_beginthread(MakeMainObjWin,NULL,245760,MPVOID) == -1) { 5852 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT)); 5853 PostMsg(hwnd,WM_CLOSE,MPVOID,MPVOID); 5866 5854 return 0; 5867 5855 } … … 6967 6955 "%s.NumDirsLastTime", 6968 6956 path); 6969 if (PrfQueryProfileData(fmprof, 6970 FM3Str, 6971 s, 6972 (PVOID) & numsaves, 6973 &size) && 6974 numsaves) 6975 { 6957 if (!PrfQueryProfileData(fmprof,FM3Str,s,(PVOID)&numsaves,&size)) 6958 Win_Error(hwnd,hwnd,__FILE__,__LINE__,"PrfQueryProfileData"); 6959 else if (!numsaves) 6960 Runtime_Error(pszSrcFile, __LINE__, "no data"); 6961 else { 6976 6962 if ((shiftstate & KC_SHIFT) == 0) 6977 PostMsg(MainObjectHwnd, 6978 UM_RESTORE, 6979 MPVOID, 6980 MPFROMLONG(2L)); 6963 PostMsg(MainObjectHwnd,UM_RESTORE,MPVOID,MPFROMLONG(2L)); 6981 6964 { 6982 6965 char *temp; 6983 6966 6984 temp = strdup(path);6985 if ( temp)6967 temp = xstrdup(path,pszSrcFile,__LINE__); 6968 if (!temp) 6986 6969 { 6987 if (!PostMsg(MainObjectHwnd, 6988 UM_RESTORE, 6989 MPFROMP(temp), 6990 MPVOID)) 6970 if ((shiftstate & KC_SHIFT) != 0 || fAutoTile) 6971 PostMsg(MainObjectHwnd,UM_RESTORE,MPVOID,MPFROMLONG(1L)); 6972 } 6973 else { 6974 if (!PostMsg(MainObjectHwnd,UM_RESTORE,MPFROMP(temp),MPVOID)) 6991 6975 free(temp); 6992 }6993 else6994 {6995 if ((shiftstate & KC_SHIFT) != 0 ||6996 fAutoTile)6997 PostMsg(MainObjectHwnd,6998 UM_RESTORE,6999 MPVOID,7000 MPFROMLONG(1L));7001 6976 } 7002 6977 } 7003 6978 } 7004 else7005 DosBeep(50, 100);7006 6979 WinSetWindowText(hwndStatelist, 7007 6980 GetPString(IDS_STATETEXT)); … … 7097 7070 char *temp; 7098 7071 7099 temp = strdup(GetPString(IDS_FM2TEMPTEXT)); 7100 if (temp) 7101 { 7102 if (!PostMsg(MainObjectHwnd, 7103 UM_RESTORE, 7104 MPFROMP(temp), 7105 MPVOID)) 7072 temp = xstrdup(GetPString(IDS_FM2TEMPTEXT),pszSrcFile,__LINE__); 7073 if (temp) { 7074 if (!PostMsg(MainObjectHwnd,UM_RESTORE,MPFROMP(temp),MPVOID)) 7106 7075 free(temp); 7107 7076 } … … 7110 7079 7111 7080 case UM_SETDIR: 7112 if (mp1) /* mp1 == name of directory to open */ 7081 /* mp1 == name of directory to open */ 7082 if (mp1) 7113 7083 return MRFROMLONG(OpenDirCnr((HWND) 0, 7114 7084 hwndMain, -
trunk/dll/mainwnd2.c
r299 r352 14 14 02 Jan 06 SHL Use QWL_USER more 15 15 02 Jan 06 SHL Map IDM_WINDOWDLG to match IBM_TWODIRS 16 17 Jul 06 SHL Use Runtime_Error 16 17 17 18 ***********************************************************************/ … … 20 21 #define INCL_WIN 21 22 #define INCL_GPI 22 23 23 #include <os2.h> 24 24 25 #include <stdlib.h> 25 26 #include <stdio.h> … … 44 45 HWND hwndMax; 45 46 } PERSON1DATA; 47 48 static PSZ pszSrcFile = __FILE__; 46 49 47 50 #pragma alloc_text(PERSON11,MainFrameWndProc2,MainWndProc2) … … 515 518 COMPARE *cmp; 516 519 517 cmp = malloc(sizeof(COMPARE)); 518 if (cmp) 519 { 520 memset(cmp, 0, sizeof(COMPARE)); 520 cmp = xmallocz(sizeof(COMPARE),pszSrcFile,__LINE__); 521 if (cmp) { 521 522 cmp -> size = sizeof(COMPARE); 522 523 strcpy(cmp -> leftdir, wa.szCurrentPath1); … … 731 732 if (!hwndCnr) 732 733 { 733 DosBeep(50, 100);734 Runtime_Error(pszSrcFile, __LINE__, "no window"); 734 735 break; 735 736 } … … 817 818 WinSetWindowUShort(hwnd, QWL_USER + 12, 0); 818 819 WinSetWindowUShort(hwnd, QWL_USER + 16, 0); 819 if (_beginthread(MakeMainObjWin, 820 NULL, 821 245760, 822 MPVOID) == -1) 823 { 824 PostMsg(hwnd, 825 WM_CLOSE, 826 MPVOID, 827 MPVOID); 820 if (_beginthread(MakeMainObjWin,NULL,245760,MPVOID) == -1) { 821 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT)); 822 PostMsg(hwnd,WM_CLOSE,MPVOID,MPVOID); 828 823 return 0; 829 824 } … … 831 826 DosSleep(64); 832 827 833 pd = malloc(sizeof(PERSON1DATA));828 pd = xmallocz(sizeof(PERSON1DATA),pszSrcFile,__LINE__); 834 829 if (!pd) 835 830 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT)); 836 else 837 { 838 memset(pd, 0, sizeof(PERSON1DATA)); 831 else { 839 832 pd -> size = sizeof(PERSON1DATA); 840 833 WinSetWindowPtr(hwnd, QWL_USER + 4, (PVOID)pd); -
trunk/dll/saveclip.c
r159 r352 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2005 Steven H. Levine9 Copyright (c) 2005, 2006 Steven H. Levine 10 10 11 11 12 Feb 03 SHL SaveListDlgProc: standardize EA math … … 13 13 01 Aug 04 SHL Rework fixup usage 14 14 24 May 05 SHL Rework for CNRITEM.szSubject 15 17 Jul 06 SHL Use Runtime_Error 15 16 16 17 ***********************************************************************/ … … 18 19 #define INCL_DOS 19 20 #define INCL_WIN 20 21 21 #include <os2.h> 22 22 23 #include <stdarg.h> 23 24 #include <stdio.h> … … 25 26 #include <string.h> 26 27 #include <share.h> 28 27 29 #include "fm3dll.h" 28 30 #include "fm3dlg.h" 29 31 #include "fm3str.h" 30 32 33 static PSZ pszSrcFile = __FILE__; 34 31 35 #pragma alloc_text(FMCLIPBOARDIN,SaveToClip,SaveToClipHab) 32 36 #pragma alloc_text(FMCLIPBOARDOUT,ListToClipboard,ListToClipboardHab) … … 34 38 35 39 36 BOOL SaveToClip (HWND hwnd,CHAR *text,BOOL append) {37 40 BOOL SaveToClip (HWND hwnd,CHAR *text,BOOL append) 41 { 38 42 HAB hab = WinQueryAnchorBlock(hwnd); 39 43 … … 42 46 43 47 44 BOOL SaveToClipHab (HAB hab,CHAR *text,BOOL append) {45 48 BOOL SaveToClipHab (HAB hab,CHAR *text,BOOL append) 49 { 46 50 CHAR *clip = NULL,*hold = NULL,*p; 47 51 ULONG len; … … 93 97 94 98 95 VOID ListToClipboard (HWND hwnd,CHAR **list,BOOL append) {96 99 VOID ListToClipboard (HWND hwnd,CHAR **list,BOOL append) 100 { 97 101 HAB hab = WinQueryAnchorBlock(hwnd); 98 102 … … 101 105 102 106 103 VOID ListToClipboardHab (HAB hab,CHAR **list,BOOL append) {104 107 VOID ListToClipboardHab (HAB hab,CHAR **list,BOOL append) 108 { 105 109 CHAR *text = NULL,**clip = NULL; 106 110 INT x; … … 150 154 151 155 152 CHAR ** ListFromClipboard (HWND hwnd) {153 156 CHAR ** ListFromClipboard (HWND hwnd) 157 { 154 158 HAB hab = WinQueryAnchorBlock(hwnd); 155 159 … … 158 162 159 163 160 CHAR **ListFromClipboardHab (HAB hab) {161 164 CHAR **ListFromClipboardHab (HAB hab) 165 { 162 166 CHAR *p,*pp,*text = NULL,**list = NULL; 163 167 INT numfiles = 0,numalloced = 0; … … 166 170 p = (CHAR *)WinQueryClipbrdData(hab,CF_TEXT); 167 171 if(p && *p) 168 text = strdup(p);172 text = xstrdup(p,pszSrcFile,__LINE__); 169 173 WinCloseClipbrd(hab); 170 if (text) {174 if (text) { 171 175 bstrip(text); 172 176 pp = text; … … 206 210 case WM_INITDLG: 207 211 if(!mp2) { 208 DosBeep(250,100);212 Runtime_Error(pszSrcFile, __LINE__, "no data"); 209 213 WinDismissDlg(hwnd,0); 210 214 } … … 296 300 strcat(szBuffer,"\\"); 297 301 strcat(szBuffer,"PATTERNS.DAT"); 298 fp = fopen(szBuffer,"w");299 if (fp) {302 fp = xfopen(szBuffer,"w",pszSrcFile,__LINE__); 303 if (fp) { 300 304 fputs(GetPString(IDS_LISTPATTERNTEXT),fp); 301 305 for(sSelect = 0;sSelect < sMax;sSelect++) { … … 313 317 fclose(fp); 314 318 } 315 else316 DosBeep(500,100);317 319 } 318 320 else if(!sMax) { … … 471 473 } 472 474 } 473 if(pci && (INT)pci != -1) { 475 if(!pci || (INT)pci == -1) 476 Runtime_Error(pszSrcFile, __LINE__, "no data"); 477 else { 474 478 fp = _fsopen(savename,"r+",SH_DENYWR); 475 if(fp) { 479 if(!fp) 480 Runtime_Error(pszSrcFile, __LINE__, "_fsopen"); 481 else { 476 482 fseek(fp,0L,SEEK_SET); 477 483 if(WinQueryButtonCheckstate(hwnd,SAV_APPEND) == 0) … … 581 587 fclose(fp); 582 588 } 583 else 584 DosBeep(250,100); 585 } 586 else 587 DosBeep(100,100); 589 } 588 590 } 589 591 WinEnableWindow(hwnd,TRUE); … … 606 608 case WM_INITDLG: 607 609 if(!mp2) { 608 DosBeep(250,100);610 Runtime_Error(pszSrcFile, __LINE__, "no data"); 609 611 WinDismissDlg(hwnd,0); 610 612 } … … 693 695 strcat(szBuffer,"\\"); 694 696 strcat(szBuffer,"PATTERNS.DAT"); 695 fp = fopen(szBuffer,"w");697 fp = xfopen(szBuffer,"w",pszSrcFile,__LINE__); 696 698 if(fp) { 697 699 fputs(GetPString(IDS_LISTPATTERNTEXT),fp); … … 708 710 fclose(fp); 709 711 } 710 else711 DosBeep(500,100);712 712 } 713 713 else if(!sMax) { … … 857 857 "SaveToListName", 858 858 savename); 859 if(list && list[0]) { 859 if (!list || !list[0]) 860 Runtime_Error(pszSrcFile, __LINE__, "no data"); 861 else { 860 862 fp = _fsopen(savename,"r+",SH_DENYWR); 861 if(fp) { 863 if (!fp) 864 Runtime_Error(pszSrcFile, __LINE__, "_fsopen"); 865 else { 862 866 fseek(fp,0L,SEEK_SET); 863 867 if(WinQueryButtonCheckstate(hwnd,SAV_APPEND) == 0) … … 886 890 CHAR *value; 887 891 888 pgealist = malloc(sizeof(GEA2LIST) + 64); 889 if(pgealist) { 890 memset(pgealist,0,sizeof(GEA2LIST) + 64); 892 pgealist = xmallocz(sizeof(GEA2LIST) + 64,pszSrcFile,__LINE__); 893 if (pgealist) { 891 894 pgea = &pgealist->list[0]; 892 895 strcpy(pgea->szName,SUBJECT); … … 894 897 pgea->oNextEntryOffset = 0L; 895 898 pgealist->cbList = sizeof(GEA2LIST) + pgea->cbName; 896 pfealist = malloc(1024);899 pfealist = xmallocz(1024,pszSrcFile,__LINE__); 897 900 if(pfealist) { 898 memset(pfealist,0,1024);899 901 pfealist->cbList = 1024; 900 902 eaop.fpGEA2List = pgealist; … … 930 932 CHAR *value; 931 933 932 pgealist = malloc(sizeof(GEA2LIST) + 64); 933 if(pgealist) { 934 memset(pgealist,0,sizeof(GEA2LIST) + 64); 934 pgealist = xmallocz(sizeof(GEA2LIST) + 64,pszSrcFile,__LINE__); 935 if (pgealist) { 935 936 pgea = &pgealist->list[0]; 936 937 strcpy(pgea->szName,LONGNAME); … … 938 939 pgea->oNextEntryOffset = 0L; 939 940 pgealist->cbList = sizeof(GEA2LIST) + pgea->cbName; 940 pfealist = malloc(1024); 941 if(pfealist) { 942 memset(pfealist,0,1024); 941 pfealist = xmallocz(1024,pszSrcFile,__LINE__); 942 if (pfealist) { 943 943 pfealist->cbList = 1024; 944 944 eaop.fpGEA2List = pgealist; … … 949 949 (PVOID)&eaop, 950 950 (ULONG)sizeof(EAOP2)); 951 if (!rc) {951 if (!rc) { 952 952 pfea = &eaop.fpFEA2List->list[0]; 953 953 value = pfea->szName + pfea->cbName + 1; … … 1064 1064 fclose(fp); 1065 1065 } 1066 else 1067 DosBeep(250,100); 1068 } 1069 else 1070 DosBeep(100,100); 1066 } 1071 1067 } 1072 1068 WinEnableWindow(hwnd,TRUE); -
trunk/dll/treecnr.c
r305 r352 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2001, 200 5Steven H. Levine9 Copyright (c) 2001, 2006 Steven H. Levine 10 10 11 11 16 Oct 02 SHL Handle large partitions … … 17 17 06 Aug 05 SHL Renames 18 18 08 Dec 05 SHL TreeCnrWndProc: disable menu items if drive not ready 19 17 Jul 06 SHL Use Runtime_Error 19 20 20 21 ***********************************************************************/ … … 39 40 40 41 #pragma data_seg(DATA1) 42 43 static PSZ pszSrcFile = __FILE__; 44 41 45 #pragma alloc_text(TREECNR,TreeCnrWndProc,TreeObjWndProc,TreeClientWndProc) 42 46 #pragma alloc_text(TREECNR,TreeFrameWndProc,TreeTitleWndProc,ShowTreeRec) … … 54 58 55 59 56 MRESULT EXPENTRY OpenButtonProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {57 60 MRESULT EXPENTRY OpenButtonProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) 61 { 58 62 static BOOL emphasized = FALSE; 59 63 … … 129 133 130 134 131 VOID ShowTreeRec (HWND hwndCnr,CHAR *dirname,BOOL collapsefirst,BOOL maketop) {132 135 VOID ShowTreeRec (HWND hwndCnr,CHAR *dirname,BOOL collapsefirst,BOOL maketop) 136 { 133 137 /* Find a record in tree view, move it so it shows in container and 134 138 make it the current record */ … … 273 277 274 278 275 MRESULT EXPENTRY TreeTitleWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {276 279 MRESULT EXPENTRY TreeTitleWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) 280 { 277 281 PFNWP oldproc = (PFNWP)WinQueryWindowPtr(hwnd,QWL_USER); 278 282 … … 288 292 289 293 290 MRESULT EXPENTRY TreeStatProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {291 294 MRESULT EXPENTRY TreeStatProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) 295 { 292 296 switch(msg) { 293 297 case WM_CREATE: … … 319 323 320 324 321 MRESULT EXPENTRY TreeFrameWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {322 325 MRESULT EXPENTRY TreeFrameWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) 326 { 323 327 switch(msg) { 324 328 case UM_RESCAN: … … 631 635 case UM_EXPAND: 632 636 dcd = WinQueryWindowPtr(hwnd,QWL_USER); 633 if(dcd) { 634 637 if (!dcd) 638 Runtime_Error(pszSrcFile, __LINE__, "no data"); 639 else { 635 640 BOOL tempsusp = dcd->suspendview; 636 641 … … 649 654 case UM_UPDATERECORDLIST: 650 655 dcd = WinQueryWindowPtr(hwnd,QWL_USER); 651 if(dcd && mp1) { 652 656 if (!dcd || !mp1) 657 Runtime_Error(pszSrcFile, __LINE__, "no data"); 658 else { 653 659 INT numentries = 0; 654 660 CHAR **list = (CHAR **)mp1; … … 667 673 case UM_SETUP: 668 674 dcd = WinQueryWindowPtr(hwnd,QWL_USER); 669 if(dcd) { 675 if (!dcd) 676 Runtime_Error(pszSrcFile, __LINE__, "no data"); 677 else { 670 678 dcd->hwndObject = hwnd; 671 679 if(ParentIsDesktop(hwnd,dcd->hwndParent)) … … 676 684 case UM_RESCAN2: 677 685 dcd = WinQueryWindowPtr(hwnd,QWL_USER); 678 if(dcd && 679 hwndStatus && 680 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) { 681 686 if (!dcd) 687 Runtime_Error(pszSrcFile, __LINE__, "no data"); 688 else if (!hwndStatus) 689 Runtime_Error(pszSrcFile, __LINE__, "no window"); 690 else if (dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) { 682 691 CHAR s[CCHMAXPATH * 2]; 683 692 PCNRITEM pci = (PCNRITEM)mp1; … … 778 787 */ 779 788 dcd = WinQueryWindowPtr(hwnd,QWL_USER); 780 if(dcd) { 789 if (!dcd) 790 Runtime_Error(pszSrcFile, __LINE__, "no data"); 791 else { 781 792 WinSendMsg(dcd->hwndCnr, 782 793 CM_REMOVERECORD, … … 849 860 850 861 dcd = WinQueryWindowPtr(hwnd,QWL_USER); 851 if(dcd) { 852 862 if (!dcd) 863 Runtime_Error(pszSrcFile, __LINE__, "no data"); 864 else { 853 865 WORKER *wk; 854 866 855 wk = malloc(sizeof(WORKER)); 856 if(wk) { 857 memset(wk,0,sizeof(WORKER)); 867 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__); 868 if (!wk) 869 FreeListInfo((LISTINFO *)mp1); 870 else { 858 871 wk->size = sizeof(WORKER); 859 872 wk->hwndCnr = dcd->hwndCnr; … … 863 876 wk->li = (LISTINFO *)mp1; 864 877 strcpy(wk->directory,dcd->directory); 865 if(_beginthread(MassAction, 866 NULL, 867 122880, 868 (PVOID)wk) == 869 -1) { 878 if (_beginthread(MassAction,NULL,122880,(PVOID)wk) == -1) { 879 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT)); 870 880 free(wk); 871 881 FreeListInfo((LISTINFO *)mp1); 872 882 } 873 883 } 874 else875 FreeListInfo((LISTINFO *)mp1);876 884 } 877 885 } … … 882 890 883 891 dcd = WinQueryWindowPtr(hwnd,QWL_USER); 884 if(dcd) { 885 892 if (!dcd) 893 Runtime_Error(pszSrcFile, __LINE__, "no data"); 894 else { 886 895 WORKER *wk; 887 896 888 wk = malloc(sizeof(WORKER)); 889 if(wk) { 890 memset(wk,0,sizeof(WORKER)); 897 wk = xmallocz(sizeof(WORKER), pszSrcFile,__LINE__); 898 if (!wk) 899 FreeListInfo((LISTINFO *)mp1); 900 else { 891 901 wk->size = sizeof(WORKER); 892 902 wk->hwndCnr = dcd->hwndCnr; … … 896 906 wk->li = (LISTINFO *)mp1; 897 907 strcpy(wk->directory,dcd->directory); 898 if(_beginthread(Action, 899 NULL, 900 122880, 901 (PVOID)wk) == 902 -1) { 908 if (_beginthread(Action,NULL,122880,(PVOID)wk) == -1) { 909 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT)); 903 910 free(wk); 904 911 FreeListInfo((LISTINFO *)mp1); 905 912 } 906 913 } 907 else908 FreeListInfo((LISTINFO *)mp1);909 914 } 910 915 } … … 918 923 hwndTree = (HWND)0; 919 924 dcd = WinQueryWindowPtr(hwnd,QWL_USER); 920 if (dcd) {925 if (dcd) { 921 926 WinSendMsg(dcd->hwndCnr, 922 927 UM_CLOSE, … … 1159 1164 CHAR *leftdir = (CHAR *)mp1,*rightdir = (CHAR *)mp2; 1160 1165 1161 if(!IsFile(leftdir) && 1162 !IsFile(rightdir)) { 1163 cmp = malloc(sizeof(COMPARE)); 1166 if (!IsFile(leftdir) && !IsFile(rightdir)) { 1167 cmp = xmallocz(sizeof(COMPARE),pszSrcFile,__LINE__); 1164 1168 if(cmp) { 1165 memset(cmp,0,sizeof(COMPARE));1166 1169 cmp->size = sizeof(COMPARE); 1167 1170 strcpy(cmp->leftdir,leftdir); … … 1305 1308 1306 1309 case UM_SETUP: 1307 if(dcd) { 1310 if (!dcd) { 1311 Runtime_Error(pszSrcFile, __LINE__, "no data"); 1312 PostMsg(hwnd,WM_CLOSE,MPVOID,MPVOID); 1313 return 0; 1314 } 1315 else { 1308 1316 if(!dcd->hwndObject) { 1309 1317 /* … … 1364 1372 MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING | 1365 1373 CMA_CXTREEINDENT | CMA_PSORTRECORD)); 1366 // CMA_TREEICON)); 1367 if(_beginthread(MakeObjWin, 1368 NULL, 1369 327680, 1370 (PVOID)dcd) == 1371 -1) { 1374 if (_beginthread(MakeObjWin,NULL,327680,(PVOID)dcd) == -1) { 1375 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT)); 1372 1376 PostMsg(hwnd, 1373 1377 WM_CLOSE, … … 1379 1383 DosSleep(1L); 1380 1384 } 1381 }1382 else {1383 PostMsg(hwnd,1384 WM_CLOSE,1385 MPVOID,1386 MPVOID);1387 return 0;1388 1385 } 1389 1386 return 0; … … 1425 1422 MPFROMLONG(CMA_FIRST), 1426 1423 MPFROMP(&pqr)); 1427 if(pci && (INT)pci != -1) { 1424 if(!pci || (INT)pci == -1) 1425 Runtime_Error(pszSrcFile, __LINE__, "no data"); 1426 else { 1428 1427 memset(&nr,0,sizeof(nr)); 1429 1428 nr.hwndCnr = hwnd; … … 1441 1440 MPVOID); 1442 1441 } 1443 else1444 DosBeep(50,100);1445 1442 } 1446 1443 break; … … 1567 1564 PCNRITEM pci; 1568 1565 1569 if(pcd) { 1566 if (!pcd) { 1567 Runtime_Error(pszSrcFile, __LINE__, "no data"); 1568 break; 1569 } 1570 else { 1570 1571 pci = (PCNRITEM)pcd->pRecord; 1571 if(!pci || (INT)pci == -1 || 1572 (pci->flags & (RECFLAGS_ENV | RECFLAGS_NODRAG))) { 1573 DosBeep(50,100); 1572 if (!pci || (INT)pci == -1) { 1573 Runtime_Error(pszSrcFile, __LINE__, "no data"); 1574 1574 break; 1575 1575 } 1576 if(hwndStatus2) 1576 if (pci->flags & (RECFLAGS_ENV | RECFLAGS_NODRAG)) { 1577 Runtime_Error(pszSrcFile, __LINE__, "drag not allowed"); 1578 break; 1579 } 1580 if(hwndStatus2) { 1577 1581 WinSetWindowText(hwndStatus2,(IsRoot(pci->szFileName)) ? 1578 1582 GetPString(IDS_DRAGROOTTEXT) : … … 1580 1584 GetPString(IDS_DRAGDIRTEXT) : 1581 1585 GetPString(IDS_DRAGFILETEXT)); 1586 } 1582 1587 DoFileDrag(hwnd, 1583 1588 dcd->hwndObject, … … 1586 1591 NULL, 1587 1592 TRUE); 1588 if(hwndStatus2) 1593 if(hwndStatus2) { 1589 1594 PostMsg(hwnd, 1590 1595 UM_RESCAN, 1591 1596 MPVOID, 1592 1597 MPVOID); 1598 } 1593 1599 } 1594 1600 } … … 1919 1925 } 1920 1926 break; 1921 } 1927 } // switch WM_CONTROL 1922 1928 } 1923 1929 return 0; … … 1940 1946 case UM_SHOWME: 1941 1947 if(mp1 && dcd) { 1942 1943 CHAR *dir; 1944 1945 dir = strdup((CHAR *)mp1); 1946 if(dir) { 1948 CHAR *dir = xstrdup((CHAR *)mp1, pszSrcFile, __LINE__); 1949 if (dir) { 1947 1950 if(!PostMsg(dcd->hwndObject, 1948 1951 UM_SHOWME, … … 1992 1995 } 1993 1996 DosError(FERR_DISABLEHARDERR); 1994 if (!DosQCurDisk(&ulDriveNum,&ulDriveMap)) {1995 if (!(ulDriveMap & 1L << (toupper(*pci->szFileName) - 'A'))) {1997 if (!DosQCurDisk(&ulDriveNum,&ulDriveMap)) { 1998 if (!(ulDriveMap & 1L << (toupper(*pci->szFileName) - 'A'))) { 1996 1999 pciL = pciP = pci; 1997 for (;;) {2000 for (;;) { 1998 2001 pciP = WinSendMsg(hwnd, 1999 2002 CM_QUERYRECORD, … … 2006 2009 break; 2007 2010 } 2008 } 2011 } // for 2009 2012 WinSendMsg(hwnd, 2010 2013 CM_REMOVERECORD, … … 2416 2419 2417 2420 case UM_COMMAND: 2418 if(mp1) { 2419 if(dcd) { 2420 if(!PostMsg(dcd->hwndObject,UM_COMMAND,mp1,mp2)) { 2421 if (!mp1) 2422 Runtime_Error(pszSrcFile, __LINE__, "no data"); 2423 else { 2424 if (!dcd) { 2425 Runtime_Error(pszSrcFile, __LINE__, "no data"); 2426 FreeListInfo((LISTINFO *)mp1); 2427 } 2428 else { 2429 if (!PostMsg(dcd->hwndObject,UM_COMMAND,mp1,mp2)) { 2430 Runtime_Error(pszSrcFile, __LINE__, "PostMsg"); 2421 2431 FreeListInfo((LISTINFO *)mp1); 2422 DosBeep(50,100);2423 2432 } 2424 2433 else 2425 2434 return (MRESULT)TRUE; 2426 2435 } 2427 else2428 FreeListInfo((LISTINFO *)mp1);2429 2436 } 2430 2437 return 0; … … 2566 2573 happ = WinStartApp(hwnd,&pgd,pgd.pszParameters, 2567 2574 NULL,SAF_MAXIMIZED); 2568 if(happ) { 2569 2575 if (!happ) { 2576 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,hwnd, 2577 GetPString(IDS_ERRORTEXT), 2578 GetPString(IDS_CANTSTARTTEXT), 2579 p,params); 2580 } 2581 else { 2570 2582 APPNOTIFY *info; 2571 2583 2572 info = malloc(sizeof(APPNOTIFY)); 2573 if(info) { 2574 memset(info,0,sizeof(APPNOTIFY)); 2584 info = xmallocz(sizeof(APPNOTIFY), pszSrcFile, __LINE__); 2585 if (info) { 2575 2586 info->happ = happ; 2576 2587 info->device = *d; 2577 if (!apphead)2588 if (!apphead) 2578 2589 apphead = info; 2579 2590 else { … … 2584 2595 } 2585 2596 } 2586 else2587 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,hwnd,2588 GetPString(IDS_ERRORTEXT),2589 GetPString(IDS_CANTSTARTTEXT),2590 p,params);2591 2597 } 2592 2598 } … … 3068 3074 ULONG action = UM_ACTION; 3069 3075 3070 li = malloc(sizeof(LISTINFO)); 3071 if(li) { 3072 memset(li,0,sizeof(LISTINFO)); 3076 li = xmallocz(sizeof(LISTINFO),pszSrcFile,__LINE__); 3077 if (li) { 3073 3078 li->type = SHORT1FROMMP(mp1); 3074 3079 li->hwnd = hwnd; … … 3119 3124 *li->targetpath = 0; 3120 3125 if(!PostMsg(dcd->hwndObject,action,MPFROMP(li),MPVOID)) { 3126 Runtime_Error(pszSrcFile, __LINE__, "PostMsg"); 3121 3127 FreeListInfo(li); 3122 DosBeep(50,100);3123 3128 } 3124 3129 } … … 3252 3257 3253 3258 3254 HWND StartTreeCnr (HWND hwndParent,ULONG flags) {3255 3259 HWND StartTreeCnr (HWND hwndParent,ULONG flags) 3260 { 3256 3261 /* bitmapped flags: 3257 3262 * 0x00000001 = don't close app when window closes … … 3283 3288 &hwndClient); 3284 3289 if(hwndFrame && hwndClient) { 3285 dcd = malloc(sizeof(DIRCNRDATA)); 3286 if(dcd) { 3287 3290 dcd = xmalloc(sizeof(DIRCNRDATA), pszSrcFile, __LINE__); 3291 if (!dcd) { 3292 Runtime_Error(pszSrcFile,__LINE__,GetPString(IDS_OUTOFMEMORY)); 3293 PostMsg(hwndClient,WM_CLOSE,MPVOID,MPVOID); 3294 hwndFrame = (HWND)0; 3295 } 3296 else { 3288 3297 SWP swp; 3289 3290 3298 WinQueryWindowPos(hwndFrame,&swp); 3291 3299 if(*(ULONG *)realappname == FM3UL) … … 3376 3384 } 3377 3385 } 3378 else {3379 saymsg(MB_ENTER,hwndParent,DEBUG_STRING,3380 GetPString(IDS_OUTOFMEMORY));3381 PostMsg(hwndClient,WM_CLOSE,MPVOID,MPVOID);3382 hwndFrame = (HWND)0;3383 }3384 3386 } 3385 3387 return hwndFrame;
Note:
See TracChangeset
for help on using the changeset viewer.